Git Product home page Git Product logo

Comments (9)

JQFonseca avatar JQFonseca commented on July 20, 2024

from defdap.

mikesmic avatar mikesmic commented on July 20, 2024

The current function has not been written a particularly generic way (for execution speed it calculates along entire rows and columns at a time) but it could be adapted easily to calculate KAM on any size square kernel. Currently it just takes the 4 nearest neighbours, so no diagonal points.

You could write a separate function that takes in a 2d array of the kernel shape (which could also include weights) and calculates KAM based on this at each point. This would have to be done at each point individually however so might be quite slow for large maps.

from defdap.

JQFonseca avatar JQFonseca commented on July 20, 2024

from defdap.

AllanHarte avatar AllanHarte commented on July 20, 2024

I have uploaded a new notebook to my repository called calculateKamNxN.ipynb. There is a function in there to calculate KAM, ignoring large local misorientations and with a flexible NxN sized kernel.

I haven't included weights (other than a weight of zero for large misorientations) and I haven't looked at Kamaya's local gradient, but I will look into including both of these.

The function works by finding the local misorientations, ignoring the large misorientations and then finding the average orientation of the small misorientations. Then the misorioentation between the pixel and the local average is obtained and stored in a KAM map array.

@mikesmic would you check that I've done the misorientation calculation properly (i.e. the Einstein summations)? I've not worked with quaternions in this way before. Maybe we could have a chat about quaternion maths at some point?

Example images of a 3x3 and a 9x9 kernel with overlaid GBs attached here...

kam 3x3 kernel:
image

kam 9x9 kernel:
image

from defdap.

mikesmic avatar mikesmic commented on July 20, 2024

I've had a look at the notebook and I'm at little confused. I can understand what you're trying to do with the first function (KAM not ignoring large values) but you can't convolve the quaternion components like you have. Addition of 2 quaternion gives the average of the 2 orientations.

I'm lost with your second function though, you seem to have done this in a different way and the maps it has produced seem reasonable. Are you in to have to talk about this today? I can run you through some quaternion maths as well, I have a crib sheet with the important stuff on.

from defdap.

AllanHarte avatar AllanHarte commented on July 20, 2024

Thanks for taking a look, I'll come to see you this afternoon about quat maths.

In the first part of the notebook I wanted to average the quat coefficients within a kernel. I did this by separating the quat data into four maps of the separate quat coefficients and then convolving that quat data with a kernel that determines the local mean for each quat coefficient. Note that I find the local mean for the individual quat coefficients and not the full orientation. I then recombine the coefficient data to get local mean orientation map for a given kernel size. The kamMap is then generated by finding the misorientation between the original data and the local mean kernel data. It's all in arrays so it's vectorised and this makes the calculation pretty quick.

In the second part of the notebook I had to do things differently to exclude large misorientations - I couldn't vectorise it. I can see how it might be a little confusing and will chat to you this afternoon about how to make it clearer. I will then update the notebook and highlight any significant changes in this thread.

Allan

from defdap.

AllanHarte avatar AllanHarte commented on July 20, 2024

After speaking with @mikesmic yesterday I realised that I was calculating the KAM in a strange way - finding local average orientations in a kernel and then the misorientation of a pixel with respect to that average. I have now changed the function so that it calculates the misorientation of a pixel with respect to its neighbours in a kernel and then it simply takes the average of those misorientations. Large misorientations are given a value of NaN, as is the central pixel's misorientation with respect to itself. The mean misorientation is therefore calculated with np.nanmean(). The result is the very similar to before but it's quicker.

When we find the KAM in this way we can easily get influences from neighbouring grains for large sized kernels. To eliminate this effect, I will try this on grain objects as opposed to the full maps

from defdap.

mikesmic avatar mikesmic commented on July 20, 2024

from defdap.

AllanHarte avatar AllanHarte commented on July 20, 2024

Ah yes, good point - as long as the maximum misOrientation value for the KAM is less than the boundary definition when loading the ebsd data then this won't be a problem, i.e. for data with maps[i].findBoundaries(boundDef = 10) then the maximum misorientation value for the KAM has to be < 10

from defdap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.