|
Kmeans图像分割:
运行环境:win7+32bit+matlab2014a
- %% 读图
- im=imread('tudou.jpg');
- % im=imread('sea.png');
- figure, imshow(im),title('原始图像');
- hsi = rgb2hsi(im);
- I = hsi(:,:,3);
- figure, imshow(I),title('亮度I图像');
- %% kmeans
- [height, width, depth] = size(hsi);
- % Label1 = kmeans_ysw(I(:), 3, 1e3);
- Label1 = kmeans(I(:), 3);
- I_kmeans1 = reshape( Label1, height, width );
- figure, imshow(I_kmeans1, []),title('Kmeans聚类图像3');
- colormap jet; axis equal
复制代码
|
|