Finding grains

My colleague asked me to help him out with this image:

Grains in an SEM image (78 pixels per micron)

Grains in an SEM image (78 pixels per micron)

He needs to know the grain size distribution, and they’ve been having trouble automating this. He knew I’d been doing some work with Mathematica’s image analysis capabilities so he thought maybe I could make some headway. This post shows my current progress.

My first idea was do use EdgeDetect to find the boundaries:

grainsedges

This is the result of using EdgeDetect in Mathematica on the original image

This seems to isolate most of the grains, but I need Mathematica to isolate the areas that the edges separate. What I decided to do was to darken up the edges by dilating them and subtracting them from the original image:

original image with edges darkened and the rest set to white

original image with edges darkened and the rest set to white

Now I use the very cool MorphologicalComponents command to get this:

overlay of the identified grains on the original image. If it's colored, it's identified.

overlay of the identified grains on the original image. If it’s colored, it’s identified.

Here’s an animation that slowly identifies the grains:

Slowly reveals the grains (the last frame is shown in the previous image)

Slowly reveals the grains (the last frame is shown in the previous image)

Cool, huh? I thought so. I’m waiting to hear from my colleague to see if this is the sort of identification he needs. My guess is that he wants something like a histogram of the areas of the grains. With ComponentMeasurements, that’s super easy:

Histogram of the areas of the grains (in square microns)

Histogram of the areas of the grains (in square microns)

Ok, so now I admit to you my ignorance. I have no idea how people do this, though I did find this standard (paywall) at the American Society for Testing and Materials (ASTM). I’m hoping some of you can help me out with refining this technique. It’s really fast in Mathematica to run it, and I think it’s pretty robust, but it does clearly miss a few grains and inadvertently joins a few.

Thoughts? Here are some starters:

  1. This is cool, but I’d love to know the exact Mathematica commands.
  2. This is dumb, there’s a much better way to do it, and here’s how . . .
  3. This is cool, can I send you all my data so that I can graduate sooner?
  4. This is dumb, we pay grad students to do this by hand so that they learn to hate. Don’t make this available.
  5. This is cool, but I bet it would struggle with . . .
  6. This is dumb, it only worked this time because . . .

 

About these ads

About Andy "SuperFly" Rundquist

Associate professor of physics at Hamline.
This entry was posted in mathematica, physics. Bookmark the permalink.

4 Responses to Finding grains

  1. jg says:

    This is very cool. I’m getting bummed that my grad program is a MATLAB shop instead of MMA.

    • Andy "SuperFly" Rundquist says:

      All of these transformations are mostly straightforward mathematical calculations done at the pixel level. Mathematica just has some nice built in functions to do them. I wouldn’t be surprised to hear Matlab has similar functionality.

  2. EMC says:

    Very cool! Reminds me of two things that were associated with my grad research. Etch pit density (EPD) characterization and Electron Back Scatter Diffraction (EBSD, specifically crystallographic orientation mapping). The whole grad student counting thing has always been a joke for EPD calculations and I think I’ve actually seen a presentation showing that the brute force (i.e. grad student) method was the most reliable for counting accurately. ImageJ has some capability for this type of analysis if you spend some time with it. As far as EBSD, I think most systems come with analysis software. Oxford has a nice page about the technique, their equipment, and their software (http://www.ebsd.com/index.php/ebsd-analysis/types-of-ebsd-experiment/representation-of-grains-and-grain-boundaries). I suspect that the U of M has an SEM with EBSD capability. As far as raw SEM image analysis though, your stuff is a about as good as I’ve seen.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s