[SOLVED] converting labelings into images

Hi guys!

I tried to find a way to convert a labeling into an image so that the pixel value of the resulting image would be determined by a labeling parameter of choice. For example if I have a labeling with 5 segments and these segments would have labels 10, 35, 23, 456 and 5. Can I convert this labeling into an image where the pixels in these 5 regions have exactly these values? Can I do it also for other labeling parameters that would require floating point pixel values?

Best,
Christian

Hi Christian,

this is not possible yet, but we can more or less easily implement such a node.

 

However, what you already can do is convert a labeling to an image, according to the underlying index of the given label list.

A labeling works internally as follows:

Labeling = Image + Mapping from Index to a list of labels.

Each value of the image is just an index of a list containing the labels at this pixel position. For example each pixel in the image with value "341"  maps on a list with labels, for example {"Hello","World","Etc"}.

Another index, lets say "5" maps on a List just containing {"Hello"} and so on.

So the Labeling to Image node extracts these indices (and writes them into an image), but not the actual values of the list.

Anyway, we could write another, very special node, which tries to extract the values of the list, convert it to numbers and creates an image (if possible). I wouldn't make such a node part of our core-framework. But I could provide the implementation etc. via some update-site if you like.

Christian

PS: Actually, this is a very nice use-case for the "ImgLib2/ImageJ2 Scripting Node" on which we are working on.

 

 

 

 

 

 

Hi Christian,

Thanks for your reply. I don't need a node for that but thank you for offering it. I just think that it's useful if I want to work with a segmentation created in Knime in other software. So far I can convert a labeling into a greyscale or a RGB image. To easily restore the segmentation with other tools a greyscale picture would be helpful in which each region that represents a unique segment in the KNIME labeling would also have a unique pixel value. I dont know whether this is always the case if you use the labeling to image node in Knime (especially if the number of segments exceeds the possible pixel values).

Christian

 

Hi Christian,

the Image to Labeling and Labeling to Image nodes do exactly what you described, I think. As you can choose the output format of e.g. the resulting image, you can control if the format can represent all individual segments (max type should be Integer.MAX_VALUE).

Float/Double is not possible yet, as we we internally fixed all Labelings to be of IntegerType (performance reasons).

Hope this helps,

Christian

 

 

 

Thank's Christian.