Image Segmentation and image saving

조회 수: 1 (최근 30일)
Rosida Octavia Sitorua
Rosida Octavia Sitorua 2021년 3월 8일
I want to read all the images in the folder, then segmented and stored in a new folder. But when the segmentation process is only one image running, everybody help me? Thank you very much.
image_folder = 'C:\Users\ADMIN\Matlab\Implementasi';
outfolder = 'C:\Users\ADMIN\Matlab\Implementasi\cobaku';
if ~isdir(outfolder); mkdir(outfolder); end
figure, fig1=imshow(citra);
files = dir(fullfile(image_folder, '*.jpg'))
%change to grayscale
grayimg = rgb2gray(citra);
figure, fig2=imshow(grayimg);
%change to green channel
green_channel = citra(:,:,2);
figure, fig3=imshow(green_channel);
%change to CLAHE (Contrast Limited Adaptive Histogram Equalization)
CLAHE = adapthisteq(green_channel);
figure, fig4=imshow(CLAHE);
ER = edge(CLAHE, 'canny');
EG = edge(CLAHE, 'canny');
EB = edge(CLAHE, 'canny');
anyedge = ER | EG | EB;
figure, fig5=imshow(anyedge)
size(fig5)
load mri %I presume it has the variable map in it
for iFiles = 1:numel(files)
thisfilename = fullfile(files(iFiles).folder,files(iFiles).name);
[~, basename, ext] = fileparts(image_folder);
citra = imread(thisfilename);
V = squeeze(citra);
fprintf('processing %s\n', basename);
fig = figure;
citra3 = montage(reshape(V,size(citra)), map, 'Indices', 3);
outfile = fullfile(outfolder, sprintf('%s-coba-%03d.jpg', basename, iFiles));
saveas(citra3, outfile);
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by