答案 0 :(得分:0)
[imagename, imagepath] = uigetfile({'*.png; *.tif;*.jpg;*.png'},'Select file');
address = fullfile( imagepath,imagename);
a = imread(address);
% figure, imshow(a);
image = imresize(a, [512 512]); %Resizing image
tic;
gchanel=image(:,:,2); %Green Chanel Extraction
% figure,imshow(gchanel);
Igchanel = imcomplement(gchanel); %Inversion
% figure,imshow(Igchanel);
conenhance = adapthisteq(Igchanel); %Contrast Enhancement
% figure,imshow(conenhance);
g = imgaussfilt(conenhance,2); %Gaussian filtering
% figure,imshow(g);
se = strel('ball',8,8) ;
tophat = imtophat( conenhance,se); %Tophat transform
% figure,imshow(tophat)
med = medfilt2(tophat); %Median filtering
background = imopen(med,strel('disk',15));
I2 = med - background; % Background Removal
% figure,imshow(med);
I3 = imadjust(I2); %Intensity Adjustment
level = graythresh(I3); % Gray Threshold
bw = im2bw(I3,level); % Binarization
% figure,imshow(I2);
figure,imshow(bw);
上面的@ Carlos Borau是我在下面给出的示例图像上尝试的代码。