Convert colormap image file into grayscale


#1

I am trying use the colored images that are generated from modules such as IdentifyPrimAutomatic for further analyses. I tried to convert them into grayscale images using the ColortoGray Module but when I get to the analysis module, the pipeline shuts down with the error dialog:

There was a problem running the analysis module IdentifyPrimAutomatic which is number 04.
Image processing was canceled in the IdentifyPrimAutomatic module because it requires an input image that is two-dimensional (i.e. X vs Y), but the image loaded does not fit this requirement. This may be because the image is a color image.

I tried a few things to get past that error. The image looks like a grayscale image, but IdentifyPrimAutomatic still identifies “0 objects”, suggesting that it just can’t interpret this as a valid image.

Thanks,

Jan


#2

I have attached a sample pipeline that I made to convert segmented images into grayscale for subsequent analysis. I have attached 2 tif files that are colored images of segmented objects, taken at different planes within the same stack. I have saved them manually because I would like to be able to use these images in various pipelines, for example: to test a pipeline in development, to resegment them under a second set of conditions or to subtract one from the other to eliminate duplicate objects.

  1. When I try to use the images in a pipeline after converting them to grayscale, I get the error message:

There was a problem running the analysis module IdentifyPrimAutomatic which is number 04.
Image processing was canceled in the IdentifyPrimAutomatic module because it requires an input image that is two-dimensional (i.e. X vs Y), but the image loaded does not fit this requirement. This may be because the image is a color image.

Stack:
CPretrieveimage in C:\Program Files\CellProfiler\CompiledCellProfilerXP325811Bugfix\CompiledCellProfiler\CellProfiler_mcr\CPsubfunctions\CPretrieveimage.m (72)
IdentifyPrimAutomatic in C:\Program Files\CellProfiler\CompiledCellProfilerXP325811Bugfix\CompiledCellProfiler\CellProfiler_mcr\Modules\IdentifyPrimAutomatic.m (515)
AnalyzeImagesButton_Callback in C:\Program Files\CellProfiler\CompiledCellProfilerXP325811Bugfix\CompiledCellProfiler\CellProfiler_mcr\CellProfiler\CellProfiler.m (10442)
gui_mainfcn in C:\Program Files\CellProfiler\CompiledCellProfilerXP325811Bugfix\CompiledCellProfiler\CellProfiler_mcr\CellProfiler\CellProfiler.m (12182)
CellProfiler in C:\Program Files\CellProfiler\CompiledCellProfilerXP325811Bugfix\CompiledCellProfiler\CellProfiler_mcr\CellProfiler\CellProfiler.m (57)

  1. I’ve had this problem in other programs as well when trying to work with masks or other overlays. What is the nature of these images? Do they have bit depth? Is there a way to convert them into a binary image that can be read on CellProfiler?

Thank you so much!

Jan
ColorToGray_for_reanalysisPIPE_JML.mat (1.04 KB)


#3

Hi Jan,

Thanks for sending the images and the pipeline. According to the pipeline as it stands now, the reason you’re getting the error is that in IdenitfyPrimAutomatic, you are using Image1 as the image you want to process. IdentifyPrimAutomatic is not equipped to handle color images, only grayscale ones. So to fix the problem, use OrigGray instead of Image1.

I think once you take this step, you’ll find that dealing with masks/overlays may be easier.

Regards,
-Mark


#4

Thanks, Mark. It worked, and it also helped me to figure out another thing that I didn’t understand about naming saved images. I appreciate it!

Jan