Label Image To RoiManager

Dear community,

While using CellProfiler (3.1.9) to analyze images with numerous cells, I stumbled on a label issue!

I need to continue the processing in FIJI, and thus I thought I will re-use @NicoKiaru’s code
But the CellProfiler’s output has multiple objects with the same label value (@CellProfilerTeam can something be done about it ?) thus I thought to use the particles analyzer to get different ROIs.

This script does the job, but the way we get rid of the “0” label (with RGB image) is a bit hacky/dummy and I was hoping for your help to come up with something better !

Here is a macro snippet to get a label image from blob

// macro to generate an image with labels

run("Blobs (25K)");


setOption("BlackBackground", true);

run("Convert to Mask");

run("Analyze Particles...", " show=[Count Masks] exclude ");

You can download Here is a larger image from CellProfiler corresponding to the preview below.

Thank you in advance for your inputs,


1 Like

Hello! That is odd… Could you elaborate on what makes you think that CellProfiler produces multiple objects with the same label value?

I wonder if you are attempting to analyze one of the visual outputs of CellProfiler (meant for display) rather than the true label matrix of CellProfiler?

Hi @AnneCarpenter,

Thank you for your quick reply!

I use the module ConvertObjectsToImage(using my cell Objects, and I tried Color, uint16 and Grayscale) and then the module SaveImages. Is there an alternative way?

Yeah, I had this exact problem a while back where basically I wanted to output just count mask of all the objects and couldn’t work it out.

Eagerly awaiting a solution!

1 Like

Hi @romainGuiet,

To my understanding the uint16 mode of ConvertObjectsToImage should produce what you’re looking for. Provided you set the SaveImages tif bit depth to ‘16-bit integer’ you should get a greyscale image rather than the colour one you posted above, with individual labels for each object.

If you’ve tried this would you mind uploading the result?


Yeah, I think this is the solution. I did a deep dive through my notes and this does seem to be what I found out eventually (but apparently forgot in the meantime!).

Here's the original image in what I think is the desired output test_Image.tiff (12.9 MB)

Hi @DStirling,

thank you for your suggestion!

That’s what I hoped but when selecting this option, and opening it in FIJI ( and photoshop :nauseated_face:), I only get an 8bit image with all pixel values at 0.
I thought that I might have more than 65535 objects ( the original image is much larger), so I tried with a smaller image ) and still get a zeros-only image.



Hi @romainGuiet,

Would you be able to send over a copy of the pipeline you’re using, perhaps with the actual output image that you obtained? It seems to work just fine in my hands.


Hi @DStirling,

Please find here a gDrive folder, with the cproj and some input and output images.

Thank you for your help with this David,



Hi @romainGuiet,

In your SaveImages modules, you need to set the ‘Image Bit Depth’ to ‘16-bit integer’ in order to export uint16 images correctly. That seems to get it working on my end.

Note that these will appear black in most photo editors, but the data is present when opened in ImageJ.

Hope that helps!


If this is indeed the solution, does anybody have ideas on what we could do to make it more easy for people to figure out? Where in the documentation would you expect to find a description of how to do this?

1 Like

The best place might be a note in module help for ConvertObjectsToImage, since saving as 8-bit isn’t strictly wrong. I assume that SaveImages tries to scale down the 16-bit range to 8-bit. Typically segmentation labels don’t use the full range, so this placed all the labels in the 0-1 range and they got lost in this instance.


Great! Do you mind adding that to 4.0?

that’s it! :tada: thank you @DStirling! I feel so dumb :upside_down_face:

I guess I’m so used to have some CellProfiler “warning message” that I didn’t think I was doing something wrong.

I would add a “warning” at the SaveImages if the input is an 16-bit image and the output is set to 8-bit.

Thank you again,



Turns out this guidance was already in the module help:

Use SaveImages to write the resulting image as a .npy file or 16-bit (not 8-bit!) .tiff file to disk if you want to process the label matrix image using another program or in a separate CellProfiler pipeline and think you are likely to have more than 255 objects in some or all of your images.

I’ll clarify the latter part.

Regarding warnings, I’m not sure if it’s feasible to have such a popup appear during module configuration, since to my understanding CellProfiler wouldn’t know what type of image is coming from another module before the actual analysis run.

1 Like

Dear all,

just to let you know that we made a small ij plugin to play with the label images.
It’s available on github and our fiji update site PTBIOP



1 Like