%input:
%inputFilename: the picture file
%nclus: the number of the clusters

%example:
%mytest('cherry.jpg',4) or mytest('car.jpg',7)


function main = mytest( inputFileName, nclus)
temp = double(imread(inputFileName));
[a,b,c]=size(temp);
for i = 1 : a
 for j = 1 : b
   data( (i-1)*b+j, :) = temp(i,j,:);
 end
end


[distance,label,tse,center] = kmeans1(data,nclus);

for i =1:a
    for j = 1:b
        lab = label((i-1)*b+j);
        temp2(i,j,:)= center(lab,:);
    end
end

temp2 = uint8(temp2);
figure; imshow(temp2);
save result label tse center
return
    



