Export groundTruth as single png image
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
Jose Agustin Barrachina
am 28 Apr. 2022
Bearbeitet: Jose Agustin Barrachina
am 28 Apr. 2022
0 Stimmen
Kategorien
Mehr zu Label Images and Video finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!