I want to save images in a folder .I want to take the images by their label (it's divided into 2 labels ) and save every label in a folder
Mostrar comentarios más antiguos
this is a function i made , i want to take the images by their label (it's divided into 2 labels ) and save every label in a folder
function test_network(net, image)
I = imread(image);
R = imresize(I, [224, 224]);
[Label, Probability] = classify(net, R);
figure;
imshow(R);
title({char(Label), num2str(max(Probability)*100, 6) })
end
please help
Respuestas (1)
Tejas
el 7 de Jul. de 2025
Hello Mahmoud,
To save an image into a folder based on its classified label, follow these steps:
- Convert the label to a string.
labelStr = char(Label);
- Use the label name to create a new folder.
if ~exist(labelStr, 'dir')
mkdir(labelStr);
end
- Use the "imwrite" function to save the image into the newly created folder. For more information on "imwrite" function, refer to this documentation: https://www.mathworks.com/help/matlab/ref/imwrite.html .
[~, name, ext] = fileparts(image);
outputPath = fullfile(labelStr, name + ext);
imwrite(I, outputPath);
Categorías
Más información sobre Import, Export, and Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!