Image Segmentation saving all image

조회 수: 1 (최근 30일)
Rosida Octavia Sitorua
Rosida Octavia Sitorua 2021년 3월 6일
Hi, I have the code to read multiple images at the same time and then proceed with the process of removing the image background. Then the code for the Canny process, and the code to change the image from grayscale to green channel, then CLAHE. I want to combine this code so that it will be composed of grayscale, green channel, CLAHE, remove background, and canny. Can anyone help me? Code for grayscale until CLAHE and Canny
citra=imresize(imread('image.jpg'),1);
figure, fig1=imshow(citra);
%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)
2. Code For read multiple images at the same time and then proceed with the process of removing the image background
image_folder = 'F:\kuliah\semester6\TA2\mencoba';
outfolder = 'F:\kuliah\semester6\TA2\mencoba\hasil';
if ~isdir(outfolder); mkdir(outfolder); end
load mri %I presume it has the variable map in it
files = dir(fullfile(image_folder, '*.jpg'));
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by