Recombining Segments back into a bitmask after classifying them, for overlay on the original image

I’m working to cluster and classify segments based on metrics pulled from ‘Image Segment Features’ node. Seems to be clustering well and I think the results are good. BUT.
I’d like to put the now clustered segments back together in the right position and relative to the proper original image so that I can colour them by cluster and overlay that on top of the original image. Basically to validate the output.
My issue here is that after running the Image Segment Features node, the resultant table is a whole bunch of individual segments and I can’t figure out how to recombine them in their original positions.

In a general sense my workflow looks like:
Image reader -> some preprocessing -> Image segment features -> Kmeans clustering -> ???

Any advice?

The individual segments in the BitMask column retain the information about their original position (called offset) in the image metadata (use the Image Properties node to find out if interested).

You can use the GroupBy node with one of the aggregation functions Compose Labeling or Compose Image (provided by the KNIME Image Processing Extension) to assemble them back as a label image or mask image, respectively. The target dimensions of the result image can be defined by selecting the source labeling in the options of the aggregation function.

2 Likes

thanks @imagejan that does the trick.