Image segmentation for optical microscope images


I am trying to segment a batch of images from optical microscope. Attached is one sample image. My goal is to separate four phases in the image and analyze the corresponding volume fraction. I used machine learning approaches implemented in trainable weka segmentation in ImageJ and ilastik, and can roughly segment phases 1, 2 and 3. However, the fourth phase pointed by black arrows, a thin white layer surrounding brown particles, cannot be properly separated from phase 2 or 3. Please let me know if you have any suggestions. Your help will be greatly appreciated.



Would you be able to share an original, unannotated image with us to test? What features did you use in Trainable Weka? Did you alter any of the default settings?

Attached please find the original image.
500x_15.tif (3.1 MB)

The following image shows the labels I added before classification:

I have tried TWS with different settings, such as adding Laplacian and Structure filters, selecting Balance classes option and increase Maximum sigma to 32 etc.

Here is the trained result using default settings. In the lower right corner, some of the matrix is wrongly classified as IL (green color), while in some other areas IL is wrongly classified as matrix.

Here is the trained result with added Laplacian and Structure features, and selected Balance classes option. Result is slightly better in the lower right corner, but could not completely remove those green dots.

If I add more labels in the lower right corner to correct the matrix, then the IL in other areas will be wrongly classified as matrix. So far, the thin white ring surrounding brown fuel particles hasn’t been considered for segmentation yet.

Hello @zgmei,

First of all, why do you use 3 classes only if you want to segment 4 phases?

I tried TWS on your image with 4 classes and these settings:

These are the results I got:

If you want to segment phase 4, you need to provide enough samples of it. For example:

I hope this helps!

1 Like


You might also want to consider some pre-processing of your images before training… perhaps that will assist in those rogue pixels being picked up in other classes.


To answer your question first, I tried to use 4 classes to segment all 4 phases, but the result doesn’t look very good. Some area of phase 1 were wrongly classified as phase 4. With your suggested settings, the result (image below) looks much better, but there are still some areas not classified correctly, such as those areas circled by red lines.

Right now, the most challenge part to me is to separate phase 2 and 3 accurately. I will try some pre-processing as etadobson suggested to see if this will help. @etadobson, can you suggest some processing? Thanks.


I"m not sure - would have to test… try a median filter… to start.

Just know that whatever pre-processing you do - has to be applied in the same exact ways to all images being processed…

No workflow will be 100%. So picking up a wrong pixel here or there is bound to happen… just depends on how much error your analysis can handle. What exactly are you trying to measure in the end? Just the areas of these regions?

Yes, our goal is to accurately measure the area fraction of each phase. Traditionally, this kind of work is measured manually by laying a grid paper over the image and counting the number of points to estimate the fraction of each phase. Very labor intensive, and not very accurate.

I understand that no workflow will be 100% accurate. Averaging results from several images may reduce the error. However, if some phases are over- or under-estimated consistently, then it could be an issue.

1 Like

@zgmei Have you tried downsampling the images a bit?

1 Like

@iarganda For some large tiff images, I did downsampling the images to save some classification time. Would downsampling make any change to the classification results?

If you are interested on the areas proportions only, it might even be helpful to save time and simplify the task of the classifier.

Yes, I am only interested in the area fractions. Do you think downsampling image won’t affect the result of classification?

Sorry for the late answer, @zgmei. Did you try downsampling your images? Sometimes (if you don’t need a fine-grain segmentation) it really helps and saves times and memory.

1 Like