how to get masks from the .mat file
11 views (last 30 days)
Show older comments
merzouk
on 7 Apr 2023
Commented: Vinayak Choyyan
on 11 Apr 2023
Hello, I am building a semantic segmentation CNN, I made my lables on matlab with image labler but I don't know how to get the masks I need to train my neural network.
Is there a way to get masks, knowing that I have several lables?
thank you and have a nice day .
0 Comments
Accepted Answer
Vinayak Choyyan
on 10 Apr 2023
Dear merzouk,
As per my understanding, you have used the Image Labeler app in MATLAB to label some images and exported the results to a .mat file. You would now like to know how to access the labels in this .mat file.
Please refer to this link https://www.mathworks.com/help/vision/ug/get-started-with-the-image-labeler.html#mw_72146e4f-e569-457d-91b9-9ac80caffb67 to know more about how to access the labels in the .mat file. The data is stored in ‘groundTruth’ format and you can read more about ‘groundTruth’ format here https://www.mathworks.com/help/vision/ref/groundtruth.html?s_tid=doc_ta.
Alternatively, if you are looking for how to read any mat file into a code, you can use the ‘load’ function to do the same. Please refer to this https://www.mathworks.com/help/matlab/ref/load.htmlto know more about ‘load’ function.
I hope this resolves the issue you are facing.
2 Comments
Vinayak Choyyan
on 11 Apr 2023
I am glad that I was able to help you.
Once you have the labels, you could use the 'label2rgb' function to convert the labels into an image. Then you could use the 'imwrite' function to save the image in tiff format by specifing the image file format.
Please refer to the following documentation to read more about
- 'label2rgb' https://www.mathworks.com/help/images/ref/label2rgb.html
- 'imwrite' https://www.mathworks.com/help/matlab/ref/imwrite.html
I hope this resolves the issue you are facing.
More Answers (0)
See Also
Categories
Find more on Recognition, Object Detection, and Semantic Segmentation 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!