Saving Output to Specified Folder Location
Mostra commenti meno recenti
Hello, I currently have a code that creates 18 arrays and saves them as .tif files. The .tif files are saved in the same folder path where my input and my code are found. However, my end goal would be to save each array to a new folder. Any help would be greatly appreciated!
4 Commenti
James Tursa
il 6 Ott 2017
Why can't you just include the path as part of the name when you save the files?
RB
il 9 Ott 2017
Image Analyst
il 9 Ott 2017
Modificato: Image Analyst
il 9 Ott 2017
For example
imageFolder = 'D:/whatever';
baseFileNameWithExtension = 'awesome.PNG';
fullFileName = fullfile(imageFolder, baseFileNameWithExtension);
% Convert any numerical array to uint8.
uint8Image = uint8(255 * mat2gray(array));
% Write to disk.
imwrite(uint8Image, fullFileName);
Did you see Walter's solution below before you posted the question?
Walter Roberson
il 9 Ott 2017
... just like I showed below.
Risposte (1)
Walter Roberson
il 6 Ott 2017
projectdir = 'TheParentDirectory\whatever';
for idx = 1 : 18
... generate YourArray
subdir = fullfile(projectdir, sprintf('ImageDir_%02d', idx));
if ~exist(subdir, 'dir')
mkdir(subdir);
end
filename = sprintf('Output_file_%02d.tif', idx);
fullname = fullfile(subdir, filename);
imwrite(YourArray, fullname);
end
Categorie
Scopri di più su Convert Image Type in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!