How to save multiple outputs of segmented in a different folder

2 vues (au cours des 30 derniers jours)
SRINIDHI GIRI
SRINIDHI GIRI le 12 Mar 2021
Commenté : SRINIDHI GIRI le 16 Mar 2021
Hello!
I have segmented 104 images, I need those segemted images to be saved in separate folder. How do I do that. Could you please help me with that.
The code used as follows
clc;
image_folder='C:\Users\Abinaya Giri\OneDrive\Desktop\Segmentation\Test_C1';
filenames = dir(fullfile(image_folder,'*.png'));
total_images = numel(filenames);
for n = 1:total_images
f=fullfile(image_folder,filenames(n).name);
I = imread(f);
s = rgb2gray(I);
imshow(s>115 & s<210);
figure(n)
imshow(s)
path = strcat('C:\Users\Abinaya Giri\OneDrive\Desktop\Segmentation\Segmented',image_folder.name);
imwrite(I,path);
end
Thanks in advance.

Réponse acceptée

Shubham Rawat
Shubham Rawat le 15 Mar 2021
Hi Srinidhi,
For saving a particular file in different folder you may use this:
save(['C:\Users\Abinaya Giri\OneDrive\Desktop\Segmentation\Segmented' filenames(1).name])
By this you will save a file of name filenames(1).name to the existing folder 'C:\Users\Abinaya Giri\OneDrive\Desktop\Segmentation\Segmented'
Note: Folder should already exist
Hope this helps!
  7 commentaires
Shubham Rawat
Shubham Rawat le 16 Mar 2021
Hi Srinidhi,
Updated my comment above
Previously you had overwrited the imshow(s) with imshow(s>115 & s<210). So, whatever file in the figure will be saved.
Thanks
SRINIDHI GIRI
SRINIDHI GIRI le 16 Mar 2021
It was perfect.....Thanks for your time

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by