How to export my masks in .jpg format with Image Labeler?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
How to export my masks in .jpg format with Image Labeler? Because actually, my mask is just a black figure with the .png format.
Louis.R
0 Commenti
Risposte (2)
Shubh Sahu
il 12 Feb 2020
The PNG file's image value is composed as 0 1 2 and you cannot distinguish the image looks like the result from following command.
image = imread('XXX.png'); imshow(image) % Looks like a black image
To see labeled image, please use the following commands.
figure; image = imread('XXX.png'); imagesc(image); colorbar
OR
figure; [i, m] = imread('XXX.png'); imshow(i,m)
OR
figure; image = imread('XXX.png'); I = imadjust(image); imshow(I);
For your reference, here is a manual how to use the saved file through the exporting functionality as below.
- How Labeler Apps Store Exported Pixel Label
0 Commenti
Lui Kirtan
il 3 Gen 2025
Hey,
I know this response is a bit late, but I wanted to share my code for exporting annotated masks from the Medical Image Labeler in .png format. The code also allows you to customize the naming convention of the annotated masks.
I used this for ultrasound tumor images stored as a .tiff stack. After annotating, just open the folder where your Medical Image Labeler session is saved before running the code.
The session folder should resemble the attached image. By default, the output will be saved in a folder named masks within the session folder. However, you can change the output folder name in the code if needed. I have also attached the code file so you can use it directly. Hope this helps : ) Let me know if you have any issues.

% Get the current folder dynamically
currentFolder = pwd;
% Get the label data from folder
labelDataFolder = fullfile(currentFolder, 'LabelData');
matFiles = dir(fullfile(labelDataFolder, '*.mat'));
if isempty(matFiles)
error('No .mat file found');
end
matFilePath = fullfile(labelDataFolder, matFiles(1).name);
load(matFilePath);
% Creates the output folder within the current folder
outputFolder = fullfile(currentFolder, 'masks');
if ~exist(outputFolder, 'dir')
mkdir(outputFolder); % Create folder if it does not exist
end
% Initialize the current number and labels
currentNumber = 1;
numImages = size(labels, 4);
for i = 1:numImages
singleImageLabels = labels(:, :, :, i);
numClasses = size(singleImageLabels, 3);
for j = 1:numClasses
binaryMask = singleImageLabels(:, :, j) > 0;
% Define the filename
filename = sprintf('FileName_%03d.png', currentNumber);
imwrite(binaryMask, fullfile(outputFolder, filename));
% Increment the file number
currentNumber = currentNumber + 1;
end
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Basic Display in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!