This may not be a strictly CellProfiler related question but I am having trouble getting the label matrix from a grayscale labeled object image.
I have used ilastik to get a probability map of a cell image that I want to segment in CellProfiler. I have successfully got the grayscale labeled image by using a ConvertObjectsToImage module and save this image as a tiff file. Here is the result:
H3+CD20Test_ProbabilitiesCell_Obj_Image.tiff (51.0 KB)
In the module help, it says that the Grayscale option creates a labeled matrix where each pixel is assigned a number specific to that object. I am wondering is there a way to extract this matrix from the grayscale image?
I have tried to read this image using EBImage package in R but it gives me a matrix with pixel intensity instead of integer labels. Here is the code I used to read in the grayscale image:
objs_img <- readImage(paste(objs_dir, "Cell_Obj_Image.tiff", sep="")) matrix(objs_img[65:74,120:129],nrow=10,ncol=10)
Here is the matrix of a section of the grayscale image:
and the image of the section:
The module help of ConvertImageToObjects reads that "This module is useful for importing a previously segmented or labeled image into CellProfiler, as it will preserve the labels of an integer-labelled input. " This grayscale image can be converted back to objects correctly using the ConvertImageToObjects module, so I take that the input must have been an integer labeled matrix?
I have read in other posts (link follows) that we can use MATLAB to extract the label matrix. I am not really familiar with MATLAB, could anyone point me in a direction?