Compute overlapping area of different labels in labeling image

Hi @stelfrich,

sorry for the delayed follow-up.

Sorry if I haven’t been very clear in my original post. Judging from your reply, you understood exactly what I was looking for :slight_smile:

In the end, this was exactly the missing piece for me, thanks for reminding me of that possibility to generate the “fragments” of overlapping labels.

At about the time of your post here, I also (re-)discovered the Compare Segments node, and it turns out that combining your approach with Compare Segments is the key to the problem here. So my strategy is as follows:

  • Generate the “fragment” label segments by doing the round-trip Labeling to Image and Image to Labeling, followed by Segment Features (also computing the size of each fragment),
  • Generate the original segments using the Segment Features node,
  • Use the Compare Segments node to determine all overlapping original labels for each fragment, and finally,
  • Use Ungroup, Joiner and GroupBy to generate the (symmetrical) confusion matrix of pixel overlaps for each pair of labels.

Here’s a screenshot:

I shared this as a component node on KNIME Hub (in case someone else might find this helpful):


No, there isn’t currently. imglib2-roi has seen a lot of development in recent years, and the possibility to combine and intersect ROIs from various sources easily is great, but this specific use case wasn’t covered yet. I submitted a pull request adding some utility methods to this end:


But I have to say, working with ImgLabelings directly in imglib2 is a bit cumbersome and so far required quite a lot of digging in the API etc., that was one reason for me in the past to prefer working with KNIME when I have to deal with image segmentations containing (potentially) overlapping objects :slight_smile:

2 Likes