1 Star 0 Fork 0

X_C/imageSegmentation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
KFCM.m 947 Bytes
一键复制 编辑 原始数据 按行查看 历史
fzy 提交于 2017-05-18 16:09 . imageSegmentation
figure
I=imread('1.jpg'); %иͼ
subplot(1,2,1);
imshow(I);
title('ԭͼ');
m=size(I,1);
n=size(I,2);
r=I(:,:,1);
g=I(:,:,2);
b=I(:,:,3);
r1=reshape(r,m*n,1);
g1=reshape(g,m*n,1);
b1=reshape(b,m*n,1);
[center1,u,obj] = kfcmFun(double(r1),4,150,2);
[center2,u,obj] = kfcmFun(double(g1),4,150,2);
[center3,u,obj] = kfcmFun(double(b1),4,150,2);
img=uint8(zeros(size(I)));
for i=1:m
for j=1:n
distance=abs(center1-double(I(i,j,1)));
k = find(distance == min(distance));
img(i,j,1)=center1(uint8(k(1)));
end
end
for i=1:m
for j=1:n
distance=abs(center2-double(I(i,j,2)));
k = find(distance == min(distance));
img(i,j,2)=center2(uint8(k(1)));
end
end
for i=1:m
for j=1:n
distance=abs(center3-double(I(i,j,3)));
k = find(distance == min(distance));
img(i,j,3)=center3(uint8(k(1)));
end
end
subplot(1,2,2);
imshow(uint8(img));
title('ͼ');
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/x_c9311/imageSegmentation.git
git@gitee.com:x_c9311/imageSegmentation.git
x_c9311
imageSegmentation
imageSegmentation
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385