Grain Boundary Segmentation


I’m a beginner in using fiji/ImageJ. I would like to identify the grain boundary and then measure the grain size. However, after using the function of the thresholding methods, I can’t identify the grain clearly. If possible, I hope someone can give me some ideas or kindly guide me to do the segmentation on the uploaded image.

Hi Vanness,
What do you mean by grains boundary exactly ? Outlining manually on an example image would help to figure it out. Is it the edge or the small dark bits?

Also for the analysis you should not put a scale bar as it will impact the intensity histogram and thus any operation relying on it like thresholding.

Hi Thomas,
Thank you so much for your reply.5x0.8x_09-1.tif (3.6 MB)
Referring to the uploaded image, the orange color circle is the grain boundary I would like to identify. The black color circle area is the inner part of the grain, the small dark bits are not the stuff I want and the thresholding methods always count them as a boundary. How can I remove those dark bits and just only identify the boundary only? Thank you.

Hmm not so easy as both have similar color.
I tried identifying regionof the mask with a minimum size but its not perfect.
Maybe with the original tiff you would get better result (I used a crop of the jpeg from the first image)

Here is a macro with the following step.
Copy pasting wont work but you can reproduce by clicking the corresponding menu (use the search bar in Fiji to help you find the menus)
After the split channel, click on the image of the channel to process (red or green work ok)

run("Smooth");
run("Split Channels");
setAutoThreshold("Li");
run("Erode");
run("Find Connected Regions", "allow_diagonal display_one_image regions_for_values_over=100 minimum_number_of_points=100 stop_after=-1");
1 Like

Hi Thomas,
Thank you so much for your help. Although the result seems not so perfect, at least I can find some grain boundaries by this method. I will try to get a better image and repeat the step you suggested.

@Vanness
Hello
Using Weka we get this.
After having transformed it into RBB you can perform a processing by applying the RGB ----> CMYK plugin.
Try.
PS: Is it a thin blade of rock? What is it?
Classified image.tif (817.4 KB)

Hi Mathew,
Thank you so much for your help. The result seems better now but I’m just wondering whether or not we can clear the spot/small figure within the grain?! Because I would like extract the grain boundary only. Also, would you mind showing me the step how to get your result? It is not a thin blade of rock, actually it is Ti alloy : )

1 Like

Hi
@Vanness
Ci-dessous:

  1. Weka works very well. Judge it…

Classified image_3.tif (817.4 KB)

  1. On the result of Weka I apply a macro:
    Obviously you need the RGB to CMYK plugin.
    https://imagej.nih.gov/ij/plugins/cmyk/index.html
macro "Macro_Grain Boundary Segmentation"  {
// Macro start
requires("1.52u");
setBackgroundColor(0,0,0);
setOption("BlackBackground",true);
img=getImageID();
setBatchMode("true");
selectImage(img);
run("Duplicate...", "title=1");
run("RGB Color");
close("\\Others");
run("Duplicate...", "title=2");
run("RGB to CMYK");
selectWindow("CMYK_2");
run("Stack to Images");
selectWindow("Y"); close("C");close("M");close("K");
setAutoThreshold("Default");
//run("Threshold...");
run("Convert to Mask");
run("Set Measurements...", "area perimeter add redirect=None decimal=2");
run("Analyze Particles...", "display add");
setBatchMode(false);
close("\\Others");
roiManager("Show All without labels");
run("Flatten");
close("Y");
close("ROI Manager");
exit("Task complete");
// Macro end
}

Y-1.tif (2.4 MB)
Can you tell me about your results, if you don’t mind + :brown_heart:.
Greetings

PS: You will have to adjust the macro to your wishes.

Use weka in:
FIJI —> Plugin —> Segmentation ----> Trainable Weka segmentation
For the tutorial: https://www.youtube.com/watch?v=8yfBHiGufFE

1 Like

Hi @Mathew
Thank you so much for your code. I try to copy your code and run another image, but the result seems not so nice and quite messy (Please see the image 2). Would you mind providing more detail on how to sort it out? I guess I can’t directly copy your code for other images?!
1.tif (12.3 MB) 2.tif (12.3 MB)

@Vanness
This second photograph is much more complex to process. I do not get conclusive results with the previous method.