
%% THIS USES ONLY THE RGB FILE. + RESHAPE

if (1) 
%%
%%http://matlabtricks.com/post-35/a-simple-image-segmetnation-example-in-matlab
image = imread('jump.jpg');     % read image

%% dowsample it

 X1 = scrop(image,30,120,50,0);
 X = dsample(X1,3,3);
 [m,n,p] = size(X);

else
    N = 45
    X = mir(N);
    sigmaX = 0.75*sqrt(N);
    %    sigmaX = 5.0;
    sigmaI = 0.1; 
end
[mm, nn, col] = size(X);
figure(1)
imagesc(X)


 V = reshape(X,[m*n,p]);
 V = double(V);

 Nc = 2;
 
%% indx = kmeans(V, Nc);
  [ctrs, indx] = myKmeans(V,Nc,20);
 disp('Kmeans out..')
 
 lab2 = reshape(indx,mm,nn);
 lab4 =fix(((lab2-1)/Nc)*255) ;

 figure(2)
 imagesc(lab4)

 %%-------------------- convert indices

 

 
 %%%return
