extract a binary image from a group of image segments

apologies if this has been asked before, but I could not find the answer to my question on the forum.

 

I have a z-stack of binary images that I want to clean up by doing some filtering. As output, I'd like to have binary images again.

Until now, I've build a pretty standard image analysis workflow:

 Connected component analysis - Segment Features - Row Filter (s) - GroupBy

On inspection with the interactive segmentation view node, the result looks great. But now what? The image writer node does not accept the output of the GroupBy node. What operation(s) do I need to do before I can produce an image from  a group of image segments?

Any help appreciated!

 

 

Hi Beijoca,

welcome to the KNIME Image Processing forum ;-). You want to write out a binary image? You can simply change the GroupBy node to produce a binary image rather than a labeling (colored image, representation of a segmentation). Just replace the "Compose Labeling" with "Compose Image" and set the settings accordingly.

If you want, I can compose a small example workflow for your.


Hope this helps,

Christian

Dear Christian,

thanks a lot for the quick reply! I tried your suggestion after coming back from vacation now, but am puzzled by the result of the “Compose Image” option of the GroupBy node. Let me try to explain:

  • The input z-stack in the example of my original question consists of 507 slices
  • My segment features node results in 8017 rows and 5 columns
    (RowID, Bitmask, Label, Source Labeling, Num Pix)
  • After filtering using the Num Pix column I have 463 rows left.
  • GroupBy node settings:
    Groups: Source Labeling
    Manual Aggregation:
    Column "Bitmask"
    Aggregation "Compose Image"
    Result image type BITTYPE
    Interval “Source labeling”

The resulting single-row table, as inspected with an image viewer node, consists of a Source labeling column that appears to contain all 8017 segments. (How is this possible after using a row filter in an upstream node? It seems that I certainly lack a basic understanding of where the segment information is stored). The Compose image column contains a stack of 507 slices, but only a subset of these slices contains segments- the rest is empty. None of the slices contains more than one segment (which is what I’d expect after filtering). The offset of the segments in all slices is off. Finally, the image writer node does not accept the output of the GroupBy node.

In short, a simple sample workflow would definitely help!:slight_smile: I’m attaching 3 slices as an example of what the input looks like (the goal is to remove segments below a certain size threshold).

best regards,
Maarten

Hi Maarten

Here is a small example workflow.

Since we have a complete Labeling we can use the Labeling to Image node. This only works because all segments are already arranged in a Labeling. If we have single segments the GroupBy node would be the way to go.

Best regards

Tim-Oliver

Thanks, Tim-Oliver, works wonderfully!