CellProfiler 3.1.9 DisplayDataOnImage and OverlayOutlines bad image quality / RGB format

In CellProfiler 3.1.9, I’m trying to create an image with data (in this case, cell number) and an outline of a segmented nucleus on top of my cells. The purpose of this is to scan through quickly for quality control purposes. When I do this with DisplayDataOnImage followed by OverlayOutlines, the underlying image seems to be normalized in a way that makes it difficult to see how bright it is (it seems like it’s sampling out of a narrower possible range of intensities than the original image). When I try OverlayOutlines without DisplayDataOnImage, the quality is fine but it returns an RGB image that has the outlines in a different channel than the underlying image (in my case, outlines in R and the underlying image in both G and B). When I save this output image as a tiff it saves as an RGB tiff that then makes it difficult to import into matlab (which is my plan B for adding the data labels). Does anyone have suggestions either for how to display the data without losing so much quality or how to get a flattened tiff out of OverlayOutlines? Thank you!

Hi @Beverly,

It’s probably worth having a look at the RescaleIntensity module. Generally the overlay modules aren’t intended to be combined with eachother. What you might want to try is generating greyscale outlines and data displays for each desired channel, then using the GreyToColor module to generate a final composite image with the channels arranged as you desire.

Thanks so much @DStirling! Using ‘RescaleIntensity’ before DisplayDataOnImage helped by itself with the image quality issue, and then as you suggested doing the DisplayData and OverlayOutlines in greyscale on black backgrounds and then combining them using GreyToColor in an RGB with the underlying picture works even better. My one remaining question would be that I’d love for the final image to have the data in red and the outline in green but then the underlying image in greyscale…is it possible to have greyscale and RGB features in the same image, or do I need to pick one?

Hi @Beverly,

If you’re working with the GrayToColor module in ‘composite’ mode, you should be able to overlay in greyscale by setting the channel color to white. You can then mix and match whichever colors you choose. You might have to play around with the weighting of each channel to get a nice balance, but that should work.

Thanks @DStirling ! That works pretty well, now my only issue is that when I go to try to save that composite (with colors white, green, and magenta) that I made in GrayToColor (the composite made from my RescaleIntensity original image, my grayscale outlines, and my grayscale data) as a 16-bit tiff I get:

Error while processing SaveImages:
(Worker) ValueError: Images of type float must be between -1 and 1.
Do you want to stop processing?

Do you have any suggestions for that? Thanks so much for your help!

Hi @Beverly,

I expect that’s a bug, would you mind sending over a copy of the pipeline at some point?

In the meantime, you might need to run RescaleIntensity on some of the other grey images you produced to bring their values back into the normal range. Alternatively this could be related to the format you’re trying to save in - it’s difficult to tell without knowing the specific image it’s having trouble with.

Hi @DStirling ,

I played a bit with running RescaleIntensity on the other gray images (the outlines and the data), and it wouldn’t let me rescale the DisplayDataOnImage output and did let me rescale the OverlayOutlines output but that didn’t seem to make a difference, possibly since it was already black-and-white? Pipeline is attached, the images are pretty big so even zipping them isn’t making them happy being uploaded, but if you need them too I can try to figure that out. Thank you so much for your help!

cell_analysis_composite_short.cppipe (52.7 KB)