Counting the results of a segmentation


I have just started to use ImageJ, so my apologies of my request has been asked previously or is ridiculously obvious to experienced users.

I am using Imagej 1.51f in Fiji. I have reasonably well managed to segment an image, using the Morphological Segmentation utility in the MorpholibJ plugin, a small portion of the result is shown above left.

I want to count all of the “basins” that MorpholibJ has created, irrespective of their colour.

In the middle is the same image which I’ve variously tried converting to grey-scale, binary and a binary mask, and threshholding, in order to use the Analyze Particles function in Fiji/ImageJ. However, despite changing the settings in a variety of ways, Analyze Particles produces the result shown on the right, i.e. it does not recognise the segments in the image. I have tried several different outputs from Morphological Segmentation, including masks, with/without dams etc., with no better results.

If anyone can tell me a relatively simple way to count the individual segments / basins, preferably without the conversions / threshholding I should be very grateful. I have a large number of large images to process, therefore manual methods, or any requiring manual intervention are of limited use.

Many thanks in advance.


@iarganda is probably the best person to respond to this.

1 Like

I’m not sure I understand the problem. Each color represents a different ID so all basins are already “counted”. Do you need to merge the adjacent segments? What is your expected output?


Thanks for responding so quickly.

All the basins are identified by the segmentation, but when I try to count them with Analyze Particles, it does not recognise separate basins where they are adjacent, rather it counts all the adjacent basins as one.

In the image above, you can see examples, such as the largest cluster, which has segmented into 10 basins, but Analyse Particles, on the right, has treated it as one item instead of 10 when counting. Therefore the total number of basins in the image counted by Analyze Particles is considerably too low.

I wish to get a number that is a count of all the individual segments / basins, even where they’re adjacent. On the example on the left, the number should be 45 (one is very faint), counting by eye. It sounds simple, but I’m afraid my ImageJ skills are very weak.

I hope that helps?



@iarganda How do you go from the segmented colorized image to ROIs in the ROI Manager? That’s what @Peter needs, right? It wasn’t obvious to me from the documentation. I admit to being in a hurry and not actually playing with it within the past few days.

@Peter If you just want total count, you can simply get the maximum value in the label image.

@ctrueden You can always threshold the label image and then get all binary objects as ROIs.

That being said, to go on with the analysis I would use the MorphoLibJ analysis tools. For example, the Intensity Measurements plugin takes the label and the grayscale images as input and provides a set of intensity statistics per label in 2D or 3D (so the labels work as 2D/3D ROIs).

I have the same problem as described here above. From MorphoLibJ I obtained a 2D morphological segmentation of cells touching each other, with watershed lines and bassins labelled by different colors. However when I go to “Analyse particles”, or when I try “Selection -> Create”, the whole field is recognized as a single entity, and not as several areas. Does the problem arise when there is no empty space between the cells?
Thanks a lot!ForumQuestion

Dear @prisca,

The image you get from the Morphological Segmentation plugin is a label image, which means each cell will have a separate value (represented with a color in the image you attached using a LUT). The regular ImageJ tools (Analyse Particles or Selection > Create) are expecting a binary image. Therefore, you have to use the analysis plugins available under Plugins > MorphoLibJ > Analyze. Try for instance the “Analyze Regions” plugin to extract morphological measurements of your cells.

1 Like

Thanks a lot for your quick answer, it works as you propose. Is there a way nevertheless to also convert the regions to ROIs, to be able to measure gray values on another image?

For that you have the Plugins > MorphoLibJ > Analyze > Intensity Measurements 2D/3D plugin. :sunglasses:

1 Like

Dear Ignacio,

Thanks a lot for your help with MorphoLibJ. Everything gets clearer for me with time and trials.

It would be convenient if the function “assign measure to label” could also indicate the number/name of the label on the image. Right now I found that it adds color-coded information, which is helpful as well.

Thanks again,

1 Like

I had the same problem. What solved it for me was setting the dam connectivity option to 8.

The analyze particle counter cannot distinguish separate particles when it is on 4 (default).

Default dam connectivity on 4

Dam connectivity on 8

Also if you select the " Watershed line" option instead of the “Catchment basins” in the result section you can directly use the particle analyzer.

1 Like

related to morpholibj … First I use the morfological segmentation and than I use de morpholibj>analize… And then label images>assign measure to label… But I don’t get the scale … Other question is how I can know what label corresponce to a measure? Do you know some extra plugging to use? Or how I use the assign measure to label? Thanks in advance