Export groundTruth as single png image
Show older comments
I would like to export my labels generated using imageLabeler any of the following:
- a png RGB image
- a 2D matrix of ImageHeightxImageWidth with the class number at each position i, j
- or the same matrix but in 3D as the one-hot-encoded version.
- If not possible, at least one image per class of any of the previous ones.
Having the vertices of each polygon is not useful for me obviously. Basically I need something I can then feed into a u-net network for semantic segmentation.
Possible outcomes:
- I saw a partial solution [here](https://fr.mathworks.com/matlabcentral/answers/381245-how-to-extract-images-from-groundtruth-object#answer_411774) but it's for rectangle labels and mines are polygons.
- According to this there is a folder called PixelLabelData which has what I need, only that I can't find it.
- I tried exporting gTruth to the workspace and then I tried `pxds = pixelLabelDatastore(gTruth)` as suggested here but I have the error `The value of 'gTruth' is invalid. groundTruth objects must contain a label definition table with PixelLabel type.`. According to this is something about the paths but the png paths are Ok, I moved nothing. The message seems to be the LabelDefinition Type parameter which is indeed weird. It's just a '7' as shown in the attached figure.
- Using `[imds,pxds] = pixelLabelTrainingData(gTruth)` as suggested [here](https://fr.mathworks.com/help/vision/ref/pixellabeltrainingdata.html) has the error message of [this](https://fr.mathworks.com/matlabcentral/answers/1616790-no-pixel-label-data-found-using-the-pixellabeltrainingdata-function) question.
I can try to implement the code myself but it seems like a lot of work and something that should already be implemented somewhere, looks to me like a quite normal application. How is this done?
I am really getting mad at this... This should have been a button inside the export options... Instead I am loosing a lot of time with a simple thing. I will eventually find the solution and post it here.
Accepted Answer
More Answers (1)
Jose Agustin Barrachina
on 28 Apr 2022
Edited: Jose Agustin Barrachina
on 28 Apr 2022
0 votes
Categories
Find more on Label Images and Video in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!