K means Segmentation function

1 view (last 30 days)
img = imread('peppers.png');
T= rgb2lab(img);
T = im2uint8(T);
nrows = size(T,1);
ncols = size(T,2);
[X,Y] = meshgrid(1:ncols,1:nrows);
I = cat(3,T,X,Y);
K = 6;
P = imsegkmeans(T,K);
Z = labeloverlay(T,P);
L = imsegkmeans(I,K);
J = labeloverlay(T,L);
I need to create a fucntion which replicates what imsegkmeans is doing right in this code. Could someone please explain with code.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!