poly2label missing a label

4 views (last 30 days)
Federico
Federico on 24 Aug 2022
Answered: Federico on 25 Aug 2022
I've tagged an image using Matlab's Image Labeler app and I'm now converting the labeling to a semantic segmentation map following this MathWorks tutorial.
In the Image Labeler, I've identified 9 classes manually, by drawing polygons directly on the image. All the variables derived from the gTruth object do contain those 9 classes (e.g.: polygonLabels, polygonLabelIDs, etc.)...
...but when I generate my semantic segmentation map using poly2labels there's not a single pixel associated with the sixth class. It's there on all the input data, but it disappears in the segmentation map: all the pixels that were within that polygon are labeled as background (i.e.: class 0).
How's that even possible?

Accepted Answer

Federico
Federico on 25 Aug 2022
I will answer my own question, hoping that it could help someone else having the same issue.
The problem does not lie in poly2labels, but rather in this part of the MathWorks tutorial:
out = gatherLabelData(gTruth,[labelType.Polygon],'GroupLabelData','LabelType')
If one of the labeled class in gTruth has just a single polygon, gatherLabelData fails in recognizing it as such. It instead creates a "polygon" for every vertex, which, of course, won't work in poly2labels.
The only workaround I found at the moment is to create at least two polygons in every class.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!