Creating binary image from SEM image of ductile dimples on fracture surface


Hi all,

I am trying to create a binary image from an SEM image with a result similar to that of this image:


This is an example of some of the images I would like to perform this operation so that I can later measure properties like size distribution of the white regions separated by the black borders:

A tip 5000x spot 4 50 us.tif (951.8 KB)

Above is the original image, but I will post a png copy so that it shows on the forum:

I have tried to use a gaussian filter with a sigma of two to smooth out the surface, then making that image a binary with this result that is much different than the above image from literature:

I also tried to subtract an image with a much larger gaussian filter (sigma = 50) before smoothing with a smaller gaussian, to try to even out any brightness inconsistencies, but the result is still different from the example:

Does anybody have any suggestions for a different way of doing this?


Difficult Particle Segmentation

I do not think you will get there just by thresholding because the dark basins have different grey values.
I would try something along marker-controlled watershed segmentation:
Yet, I to not think that the top figure in the example posted is returning a meaningful result when compared to the original.

1 Like

Hi @cgusbecker,
in your example, watershed transformation was most likely used. When combined with imextendedmin function in Matlab it can be used to tweak the size of the generated clusters with following results:

Best regards,


Perhaps these ImageJ plugins are worth exploring:

1 Like

here is a video how to get this kind of results in MIB (it is a different data, but just shows the idea).

Since you have multiple 2D images you can select them all using Shift+mouse click, after that use the right mouse button to call a popup menu and choose “Combine selected datasets”.

The pixels are clustered to superpixels in Graphcut tool and exported back as a model. The superpixels can be quantified: Menu->Models->Model statistics to get their areas or any other relevant parameters.

If you want to do that in more controllable way, interactive marker-controlled watershed is a good option. Or you can try the mentioned ImageJ plugins, or Object Separation tool in MIB.


Hi Ilya,
Can you please give a few more details on the steps needed to perform this segmentation?
I have tried working with imextendedmin and watershed but couldn’t get anything close to what you show in these images. I am new to this type of image processing.
I may try MIB later but meanwhile I want to understand what it is being done.


Sure @florin,
here is an explanation in Matlab, but it cab be easily repeated in any other language.

% load image
I = imread('image.png'); 


% Do extended-minima transform to find local minima;
% the larger 'factor' value gives bigger clusters
factor = 15;
mask = imextendedmin(I, factor);


% use impose minima function to modify the image using the mask
% the masked area becomes black (0) on the original image, which will
% limit number of clusters during the following watershed step
I2 = imimposemin(I, mask);


% finally use watershed to generate the clusters
labels = watershed(I2);
imtool(label2rgb(labels, 'lines'));



1 Like

Thank you @Ilya_Belevich !
It is very helpful!
Unfortunately it does not work as easily on my own images. I will have to find another way to prepare the mask for the watershed function. Currently reading about the different possibilities.
Best regards,


try to post some example images here, perhaps someone might suggest a good solution.


Hello All,
ImageJ/ Fiji has a plugin in Plugins and available on the site simply named Watershed. With it you are asked for a Gaussian smoothing value . The higher the value, the larger the ‘Basin’ size. At a value at 20 it matched your large basin reference and a value of 5 matched your small basin reference.
Hope this helps,


Dear @Ilya_Belevich,

For you and all other who may be able to help, here is a sample image.

image.tif (3.3 MB)

It shows fine grains on the fracture surface of a brittle metallic material. Showing what corresponds to about 1.5 microns in reality, it was taken at high magnification on an electron microscope. On the microscope side I cannot do much better as focus or contrast.

After some research I found that the method described starting at page 17 in the following article may provide a good solution. I just have to learn how to code all this :sweat_smile:

S. Beucher, “The watershed transformation applied to image segmentation,” 10th Pfefferkorn Conf. on Signal and Image Processing in Microscopy and Microanalysis, 16-19 sept. 1991, Cambridge, UK, Scanning Microscopy International, suppl. 6. 1992, pp. 299-314

Thank you for your attention,


Dear @florin,
Interesting. How did you implement the 2nd function in Figure 16b (it says “dilating the previous function f1 by a cone”). Thanks.


Dear @florin,
indeed your image is not directly suitable for watershed, since it is missing ridges. The ways around it to generate those by using a gradient filter, but I believe it won’t be enough for your case. Mostly because it looks that at some angles the gradients aren’t strong.

Out of curiosity, have try to use backscattered electron detector instead of SE?

Best regards,


Hello florin,
I am interested in ‘what’ data you want to collect.
I have attached a slightly different view of the image you sent for reference.
Unzip it and open it in 3D Viewer for a better view, then try to describe to us what data you want for analysis. There are many ways to aquire the data so we would like to help in the best way for your needs. (3.9 MB)

Just curious,


combination of various filters and morphological operations can give you somethings like this:

There are many steps, perhaps some of those are not even needed, just will write them here before I forget…

  1. Original (crop)
  2. Image filtering (BM3D, K%=6)
  3. image bottom hat filter (with disk size 40) and subtraction of that from image in 1
  4. image erode (disk, size 2)
  5. stretch the contrast (0->0, 160->255)
  6. image erode (disk, size 10) and subtract result from 4
  7. BM3D filter again (K%=18)
  8. Watershed with imextendedmin factor = 15;

Best regards,


Dear @Ilya_Belevich,
The images taken with the back scattered electron (BSE) detector contain even less topographical information. The grains of my sample have the same composition. I have not tried under the observation conditions used for this sample but I doubt that switching to BSE will help. I will try next time I do SEM imaging work.


Thank you @Ilya_Belevich!
This is getting close to what I need.
I think I forgot to mention that I am interested in doing particle analysis on the grains. The facets of the grains do not interest me. This may make the task easier. The last image appears over segmented from this point of view.
Best regards,


Dear @smith_robertj,
Thank you for the file and the question!
The analysis I want to do is particle analysis. Distribution of sizes, aspect ratio… haven’t decided yet what type of size.
I am not yet enough of an expert in image analysis to know how to pass from one of your images to a segmented image.
Best regards,

For @gabriel,
I haven’t gotten to the point where I need to dilate “the previous function f1 by a cone”, I am beginner and also running into problems because of the particularities of my images.
From what I read on the internet, one can define a custom ‘non flat structuring element’ (or ‘non flat kernel’). If you are using Matlab a starting point would be the this link :
It appears that one has to build a (I would square for a cone) matrix of the size you need and containing values that define a cone, bordered by specific neutral values (-Inf for Matlab). I do not know what value should correspond to the apex of the cone.
Hope this helps,


Dear @florin,

The grains of my sample have the same composition

well, this indeed will limit usability of BSE.

The last image appears over segmented from this point of view.

it is indeed, the oversegmentation can be further optimized for certain area/particles but it may screw particles in other parts of the image. May be the next step is to use marker controlled watershed over this image.

1 Like

Hi Florin,

You will be an expert in no time. I’m on a different mail stop and pressed for time so I cannot give a detailed description at this moment but I will shortly. What you want to do is very do-able and I will send samples of some types of measurements and
how to obtain them.

Untill then look at the images in the 3D Viewer to get accustomed to the view for references.

Later (but not long),