OTSU阈值分割的实例

https://www.docin.com/p-635866924.html
关于这片文章自己的实现
clear;
clc;
I=imread(‘d:\新建文件夹\724.jpg’);
figure();
imshow(I);
title(‘原图像’);
c=makecform(‘srgb2lab’);
I_lab=applycform(I,c);
ab=double(I_lab(:,:,2:3))
nrows=size(ab,1)
ncols=size(ab,2)
ab=reshape(ab,nrows*ncols,2)
ncolors=3;
[cluster_idx,cluster_center]=kmeans(ab,ncolors,‘distance’,‘sqEuclidean’,‘Replicates’,3);
pixel_labels=reshape(cluster_idx,nrows,ncols);
figure()
imshow(pixel_labels,[]);
title(‘聚类结果’);
segmented_images=cell(1,3);
rgb_labels=repmat(pixel_labels,[1 1 3]);
for k=1:ncolors
color=I;
color(rgb_labels~=k)=0;
segmented_images{k}=color;
end
figure();
imshow(segmented_images{1});
title(‘分割结果——区域1’);
figure();
imshow(segmented_images{2});
title(‘分割结果——区域2’);
figure();
imshow(segmented_images{3});
title(‘分割结果——区域3’);
在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值