主要任务是消除叶子的复杂背景,并从MATLAB中的遮挡叶子图像中提取目标叶子.为了消除背景,我已经应用了K-means聚类算法.现在的主要任务是使用分水岭分割算法从遮挡的叶子中分割叶子.我无法为每一片叶子找到完美的片段.请帮我.我上传了样本图像以及分水岭分段代码.
原始图像

使用K-Means聚类算法消除背景后的图像和叠加在原始图像上的分水岭分割

我希望主中间叶片是单个片段,以便我可以提取它.
我在下面给出了分水岭分段代码
function wateralgo(img)
F=imread(img);
F=im2double(F);
%Converting RGB image to Intensity Image
r=F(:,:,1);
g=F(:,:,2);
b=F(:,:,3);
I=(r+g+b)/3;
imshow(I);
%Applying Gradient
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(I), hy, 'replicate');
Ix = imfilter(double(I), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
figure, imshow(gradmag,[]), title('Gradient magnitude (gradmag)');
L = watershed(gradmag);
Lrgb = label2rgb(L);
figure, imshow(Lrgb), title('Watershed transform of gradient magnitude (Lrgb)');
se = strel('disk',20);
Io = imopen(I, se);
figure, imshow(Io), title('Opening (Io)');
Ie = imerode(I, se);
Iobr = imreconstruct(Ie, …Run Code Online (Sandbox Code Playgroud)