How to save segmented images into different folders?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Anonymous26
am 8 Nov. 2018
Bearbeitet: Anonymous26
am 3 Jan. 2019
I have written a code to segment some images and save those images into different folders.
Program should work like below:
- Image 01 --> Segmentation --> Save segmented images into first folder & so on.
But my problem is;
- The segmented images are getting saved into only one folder.
I want some help to save the segmented images into different folders.
Please help.
Thanks!
0 Kommentare
Akzeptierte Antwort
Guillaume
am 8 Nov. 2018
Bearbeitet: Guillaume
am 8 Nov. 2018
Well, clearly the code you wrote has a bug but it's hard for us to tell you the problem if you don't show us the code.
It is trivial to save an image in whatever folder you want. The simplest way to do that:
destinationfolder = 'C:\somewhere\somefolder'; %folder path generated however you want
imwrite(yourimage, fullfile(destinationfolder, 'nameofimage.png'));
5 Kommentare
Guillaume
am 9 Nov. 2018
With the full code, the problem is obvious. I would expect that when you run your code you get repeated warnings from mkdir that folders already exist. The important bits of your code summarised to show the problem:
for each file (j loop)
do some processing
for each file (k loop)
create destination directory
assign destination directory to outputfoldername
end of k loop, outputfolde is thus the directory of the last file
save images of file j into outputfolder
end of j loop
The fix is simple replace the whole k loop by:
outputFolder = sprintf('Cropped Images%d', j);
mkdir(outputFolder);
As I mentioned before, I would recommend you use full path for your output folder rather than relative path. You already use full paths for your input folders. Note that fullfile is safer than strcat to build paths.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!