Export groundTruth as single png image
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jose Agustin Barrachina
le 27 Avr 2022
Commenté : Birju Patel
le 5 Mai 2022
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.
0 commentaires
Réponse acceptée
Birju Patel
le 5 Mai 2022
As you noticed, you will have to use pixel labels instead of polygons to get to a label matrix directly from the image or video labeler apps. The label matrix is saved in a PNG file when the label type is pixel label.
However, if you have polygon labels, you can use POLY2LABEL to convert them to label matrices that can be saved as PNG files using IMWRITE:
0 commentaires
Plus de réponses (1)
Jose Agustin Barrachina
le 28 Avr 2022
Modifié(e) : Jose Agustin Barrachina
le 28 Avr 2022
2 commentaires
Voir également
Catégories
En savoir plus sur Create Team-Based Image Labeling Project dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!