Image Labeler - Pixel Label from binary mask

Hello,
I've done some image segmentation with cluestering algorithm and the color tresholder app.
Is it possible to import these mask (from the segmentation) into pixel Label in the image Labeler app?
Thank you to anyone answering.
Best regards,
Turimo

Answers (1)

Hi Turimo,
I understand you have few image segmentations generated using clustering algorithm and the ‘Color Thresholder App’ and would like to import it as labels in the ‘Image Labeler App’. You could try the steps below to achieve the same.
  • Export the binary mask generated in ‘Color Thresholder App’ to MATLAB workspace and save it into an image.
imwrite(BW,'yourImageLabel.png')
  • Run the following script
dataSource = groundTruthDataSource({'sourceImg.jpg'});
ldc =labelDefinitionCreator();
addLabel(ldc,'LabelName',labelType.PixelLabel);
labelDefs = create(ldc);
dataFile = {'yourImageLabel.png'};
labelData = table(dataFile,'VariableNames',{'PixelLabelData'});
% groundTruth class is the supported object format to upload labels in image labeler app
gTruth = groundTruth(dataSource,labelDefs,labelData);
  • Open ‘Image Labeler App’. Click on Import->Labels->From Workspace. Select ‘gTruth’ from the table.
I hope this helps.

Products

Release

R2022a

Asked:

on 24 May 2022

Answered:

on 10 Oct 2023

Community Treasure Hunt

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

Start Hunting!