how to get masks from the .mat file

5 views (last 30 days)
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 .

Accepted Answer

Vinayak Choyyan
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
merzouk
merzouk on 11 Apr 2023
Thanks for your help but I wanted to have a mask in tiff or png format from the .mat file same as we can get with labkit of imagej do you think that's possible ?
Vinayak Choyyan
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
I hope this resolves the issue you are facing.

Sign in to comment.

More Answers (0)

Categories

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

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!