我有一张纹理图片,想使用 K-mean 算法对其进行分割。我写:
clc;clear;
I=imread('jyFMW.jpg');
[r c]=size(I)
%figure
%imshow(I)
%imhist(I)
R=double(I(:));
k=5;
[IDX,C]=kmeans(R,k);
B=zeros(size(C));
B(find( C == 1 )) = 0;
B(find( C == 2 )) = 50;
B(find( C == 3)) = 100;
B(find( C == 4 )) = 150;
B(find( C == 5 )) = 200;
S=reshape(B,r,c);
figure
imshow(S)
但我不确定这一点,你能帮帮我吗?我需要这样的结果:http: //upload7.ir/images/91105509914760477547.jpg
对于此输入图像:http:
//upload7.ir/images/20702551133388585947.jpg