Findmaxima fails

Tags: #<Tag:0x00007fd540301318>


I have an image that contains outlines (e.g. of nuclei) saved from CellProfiler that I wish to convert to ImageJ-ROIs
The image contains the shapes on a black background, each shape has a different grayscale value:

To segment the objects and convert the Objects to ROIs I’ve tried Findmaxima, which works very well but somehow misses some objects (see two out of several examples marked in the screenshot). Its the same image with a different LUT.

Am I using the function wrong, is it maybe a bug or would there be even a better solution to achieve what I am trying to do?


Hello @CellKai,

I’m not so sure about what you want to achieve after. Do you want to have a Roi for each cell ? Or do you want to measure some properties for each cell ?

From your image you can easily extract a mask per cell. For instance the following IJ1 macro:

run("Image Expression Parser (Macro)", "expression=A=="+valueCurrentCell+" a="+myImageName);

will generate a image mask for the cell number 80.

You can build on this macro to measure features or creates ROI.
There may be of course better options that I’m not aware of.



Thanks @NicoKiaru!
For the beginning I would like to have one ROI that contains all cells.


From what you’re showing above, I suppose you want one multi-point ROI (as opposed to a mask of all cell area), right?

Anyhow, Find Maxima is the wrong tool for that, as it does what the name suggests: it finds points that have locally maximal intensities. If you apply that to a label image (where each object has a different indexed intensity value), then you’ll get the “brightest” cell only for each cluster of touching cells, as you experienced.

BTW, for label images I recommend choosing a more suitable look-up table (LUT), e.g. glasbey or glasbey_inverted.

What’s your final goal? What do you need the point selection for? Would it be sufficient to get the centroid coordinates for each object in a table? There’s many possibilities…


I believe what @CellKai wants is to use Analyze Particles… on his label image, but he can’t unless he converts it to a binary image with borders between the touching cells.

The following macro should work given you have MorphoLibJ installed:

run("Label Boundaries");
setAutoThreshold("Default dark");
setThreshold(0, 0);
setOption("BlackBackground", true);
run("Convert to Mask");
imageCalculator("Add create", "nuclei_outline_000001.png","nuclei_outline_000001-bnd");
selectWindow("Result of nuclei_outline_000001.png");
run("Analyze Particles...", "  show=Outlines display");

This is my output:


Hi everyone, thanks for your feedback and helpful tips. Sorry for my imprecise question.

My goal to get and store the ROI around each nucleus in the ROI manager.

as @imagejan has pointed out, findmaxima failed as it gives only the [quote=“imagejan, post:4, topic:6485”]
“brightest” cell only for each cluster of touching cells

@iarganda thanks for introducing me to MorphoLibJ, that looks powerful. However, in the result you have posted there are still touching objects that where not separated.

I got the results I was looking for using an approach with thresholding followed by Analyze Particles + Watershed as @iarganda pointed out:

setThreshold(1, 255);
setOption("BlackBackground", true);
run("Convert to Mask");
run("Create Mask");
run("Analyze Particles...", "size=0-inf add");

Here is what I get:

I suppose my initial train of thought went completely into the wrong direction :slight_smile:Thanks for your help!


I noticed that, however the objects are separated by a line. It is probably a problem of Analyze Particles using a different connectivity than MorphoLibJ when creating borders.


While this might give you a reasonable result, it is just pure coincidence if the cell borders after the watershed match those from your original label image…

To analyze each object exactly as defined by its label index, I think there is no other way than to loop over each object. You can also have a look at the 3D Manager from the 3D Suite by @ThomasBoudier (just activate the 3D ImageJ Suite update site; it should also work on 2D :slight_smile:) :

  • Start the 3D object manager via Plugins > 3D > 3D Manager
  • Add your objects using Add image on your label image
  • Then Measure 3D to get the measurements per object

My preferred way however to analyze those would be a small KNIME workflow (because it’s super easy to set up, and you get all feature calculations you can think of “for free”, without having to think about how to script it…). I attached an illustrative workflow with your image here:

Analyze Label Image.knwf (35.1 KB)


Just to add more options to what @imagejan said, MorphoLibJ contains as well intensity and morphometric measurements based on label images.


Hi @CellKai, @imagejan, @iarganda

To complete the story about 3D measurements, note that the 3D measurements in the 3D suite has a shortcut 3D geometrical measure, that will perform 3D measurements directly from a labelled image.
Note also that for 2D measurements I would still recommend using the analyse particles from ImageJ/Fiji since some 3D measurements may not work as expected with 2D objects, such as area (that will not be the perimeter for 2D objects), and related shape measurements like sphericity or compactness.