Image Segmentation and Saving image
1 回表示 (過去 30 日間)
古いコメントを表示
Rosida Octavia Sitorua
2021 年 2 月 25 日
コメント済み: Rosida Octavia Sitorua
2021 年 3 月 8 日
hello I'm a final year student using Matlab for image segmentation but I have a problem. How do I save multiple pictures automatically? Please help, thank you
image_folder = 'C:\Users\ADMIN\Matlab\Implementasi';
outfolder = 'C:\Users\ADMIN\Matlab\Implementasi\output';
if ~isdir(outfolder); mkdir(outfolder); end
load mri %I presume it has the variable map in it
files = dir(fullfile(image_folder, '*.jpg'));
% filenames = fullfile({fileinfo.folder}, {fileinfo.name});
% total_images = numel(filenames);
for iFiles = 1:numel(files)
thisfilename = fullfile(files(iFiles).folder,files(iFiles).name);
% for n = 1 : total_images
% thisfile = filenames{n};
[~, basename, ext] = fileparts(image_folder);
citra = imread(thisfilename);
V = squeeze(citra);
fprintf('processing %s\n', basename);
citra3 = montage(reshape(V,size(citra)), map, 'Indices', 3);
outfile = fullfile(outfolder, sprintf(['%s-coba-%03d.%s',basename,ext]));
saveas(citra3, outfile);
end
0 件のコメント
採用された回答
KALYAN ACHARJYA
2021 年 2 月 25 日
There are multiple threads are avalible on simmilar questions, please see my answer
More:
2 件のコメント
KALYAN ACHARJYA
2021 年 2 月 25 日
Try with this way: Set the Current working directory in Input Folder Path
path_directory='...'; % 'Input Images Folder name Only'
original_files=dir([path_directory '/*.jpg']); % Folder Images in the same Directory
........................................^ Modify as per input images format
folder='output_folder'; % Create Folder to Save Results
for k=1:length(original_files)
filename=[path_directory '/' original_files(k).name];
image_orginal=imread(filename);
%%.Do Operation
result=
fullFileName = fullfile(folder, original_files(k).name);
imwrite(result,fullFileName);
end
その他の回答 (1 件)
Rosida Octavia Sitorua
2021 年 2 月 27 日
2 件のコメント
KALYAN ACHARJYA
2021 年 2 月 28 日
Oh, this is partial code, the result, I represent the output image, which you want to save. Consider your output image there and change the result variable name accordingly.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
