필터 지우기
필터 지우기

How to write the labeled images for training a sematic clssifier without using image labeler?

조회 수: 1 (최근 30일)
Hi,
I want to train a semantic classifier through images made from a simulation process, I have the ground truth classification, and therefore I don't need the image labeler app.
However, I found explanation only on how to write ground truth by the image labeler app, or by commands which add labels inside a rectangle, etc...
However, I have the ground truth image with all the labels, I just want to save it in a proper manner and traing a sematic classifier from matlab, how do I do that?
I also looked in an example ground truth data, it looks like a color image, how do I write this color image from the labels?
Please help!
Thanks,
Dr. Tal Nir

채택된 답변

awezmm
awezmm 2019년 7월 25일
편집: awezmm 2019년 7월 25일
After labeling, you should have two sets of images. The first set will be the original images and the second set will be the categorial images with labels.
For semantic segmentation you should create datastores:
imds = imageDatastore(imgDir); %corresponding to the original images
pxds = pixelLabelDatastore(labelDir,classes,labelIDs); %corresponding to labeled images
The example link above explains this in more detail.
Note that imgDir and labelDir can simply be a cell array of the filepaths to the images, in corresponding order
For instance:
imgDir = {"~/Users/awz/img1.tif", "~/Users/awz/img2.tif", "~/Users/awz/img3.tif"};
labelDir = {"~/Users/awz/label1.tif", "~/Users/awz/label2.tif", "~/Users/awz/label3.tif"};
classes = ["class1", "class2", "class3"];
labelIDs = [1 2 3];
imds = imageDatastore(imgDir);
pxds = pixelLabelDatastore(labelDir,classes,labelIDs);
  댓글 수: 1
Tal Nir
Tal Nir 2019년 7월 29일
It took me some time to build and test the code incorporating your answer, but at the end its worth the effort, it works very well.
Thank you very much for your help!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by