Applying constant contrast across image + Removing particles of certain pixel size - New user

Hi all, I am very new to image analysis with ImageJ and currently I am trying to do a grain size analysis on fault rock types from within a rock avalanche. I have acquired images from an SEM at various magnifications (x150, x400, x800, x1600) which I have montaged together in photoshop.

Currently I am struggling with the following, if any advice were to imparted I would be truly grateful.

  • Obtaining constant contrast across the images, currently the SEM has left a remnant change in contrast across the images which affects how the well the montage can be thresholded. Is there a way to amend this in ImageJ?

  • Removing particles of a certain size from the images? I would like to remove pixels of low resolution from each magnification to allow for better thresholding but I am unsure how to execute this in ImageJ.

I have attached a link for the x400 magnification montage, if there are any other suggestions to make sure for excellent analyses I am all ears.

Thank you for your time,

James L



I don’t really understand the first problem. Could you point out in your images where one sees this change in contrast? Is it a gradient over the entire image or are these stripes? How do they negatively affect the segmentation?

There are different ways to deal with uneven contrast depending on the nature of the defect. But one could also go for a more absolute intensity independent segmentation method for example based on edge detection or segmentation by machine learning (WEKA segmentation:

Once you have the segmentation result, the binary mask, you can use a size filter in the Analyze Particles…(***Analyze > Analyze Particles…***) You can define also as new output a mask with only the objects you want or work with the ROIs in the ROI Manager.


Hi there,

While Photoshop is a convenient tool to do such things, if you want to deal with uneven contrast, you have to do this before the montage. Moreover it would not appear very scientific to say ‘we used photoshop to montage the images’.
[EDIT] I noticed also that your final iamge is RGB, which means that your data was modified from the original EM images, which are usually 16-bit gray images… Avoiding image type conversions is a good rule.
Luckily ImageJ has tools that allow you to automatically montage most image types. It’s called by Herr Professor @StephanPreibisch.

And before running that step you could look into histogram equalization using with 0% saturated pixels.

In order to do that you’d need to do the following

  1. Open all your individual raw files as a stack in ImageJ (using…)

  2. Use Equalization, as per above

  3. Resaving the individual TIFF files using File > Save As > Image Sequence

  4. Using Grid/Collection Stitching to try and stitch the dataset automatically.

Now onto your question, which is slightly ill posed. What is “grain size analysis”? I am sure that this has been done numerous times in the field, is there any protocol you are basing yourself on?
At the given magnification, you will have a hard time finding the much smaller grains, they are 2-3 pixels in size.

Like @schmiedc said, once you’ve corrected for the contrast changes, your best bet is probably machine learning segmentation with Weka or Ilastik, but I would look at that litterature and see what other tools are used to asses grain size before going your own way.

Hope this helps.


1 Like