k-mean聚类准确率matlab,如何在matlab中使用k-means聚类来获得准确的聚类

我正在做一个植物病害检测项目。我需要从叶子的图像中提取患病部分,但我无法使用k-means准确地分离出患病区域。具体地说,叶子的其余部分在图像上可见,并且病变部分被分割。这是提取患病部位后的原始图像和图像:original image image after separating diseased parts

这是我写的代码

b=imread('12.jpeg');

G=fspecial('gaussian',[200 250],1);

Ig=imfilter(b,G,'same');

figure,imshow(Ig);

conversionform = makecform('srgb2lab');

lab_img = applycform(Ig,conversionform);

figure,imshow(lab_img);

ab = double(lab_img(:,:,2:3));

nrows = size(ab,1);

ncols = size(ab,2);

ab = reshape(ab,nrows*ncols,2);

nColors = 2;

[cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ...,

'Replicates',3);

pixel_labels = reshape(cluster_idx,nrows,ncols);

figure, imshow(pixel_labels,[]), title('image labeled by cluster index');

segmented_images = cell(1,3);

rgb_label = repmat(pixel_labels,[1 1 3]);

for k = 1:nColors

color = lab_img;

color(rgb_label ~= k) = 0;

segmented_images{k} = color;

end

figure, imshow(segmented_images{1}), title('objects in cluster 1');

figure, imshow(segmented_images{2}), title('objects in cluster 2');

e=segmented_images{1};

figure,imshow(e);

conversionform = makecform('lab2srgb');

new_image=applycform(e,conversionform);

figure,imshow(new_image);我想用K均值聚类只提取患病区域。如果有人能帮助我,我将不胜感激。我正在使用matlab 2009a。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值