Label/segment mapping for nested annotations

I’d like to retrieve a 1:1 mapping of segment IDs to labels created by the Interactive Annotator node.

What I have looks like this:

image image

That is: three nested segments, two of which are labeled with the same class (Class 2).

From these, I’d like to get the following information:

Segment ID        Label
----------        -------
Segment: 0        Class 1
Segment: 1        Class 2
Segment: 2        Class 2

Is there an easy way to get this information?

Using the Segment Features node, I can extract the overlap information (allowing partial overlap or not):

image

image

But I didn’t find a good way to get a one-to-one mapping because of the nested hierarchy of the segments. Also comparing their size doesn’t work, as Class 2 is the sum of Segment: 1 and Segment: 2.

@gab1one, @stelfrich any advice? :slight_smile:

Here’s the workflow I used for testing:

Nested Annotations.knwf (43.4 KB)

Hi @imagejan,

take a look at 11501.knwf (46.4 KB). The idea behind the workflow is to identify the “inclusions” in Classes and get rid of the outer one in the LabelDependencies.
My proposed solution is a bit involved but you might be able to improve on the idea…

Best,
Stefan

2 Likes

Thanks a lot, @stelfrich, for this illustrative example!

While this probably covers my current use case well (where I indeed have only full inclusions), I noticed that the logic would need to be adjusted if you also want to cover cases where segments are partially overlapping, as this is currently not handled well.

I’m surprised how complicated it is to “recover” that mapping information from the labeling output, and wondered if it could instead be provided (e.g. as a second output) by the Interactive Annotator node itself. The unique segment ID is added here:

…, so if we kept track of the connection between that newly generated segment ID and the current e.getLabels() and provide those in a simple output cell (or table, which would also require keeping track of the current RowID), things would become a lot easier.

2 Likes
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.