clc
clear all
close all

orig=imread('DSC04632.jpg');
orig = imresize(orig,0.25);
copy=orig;
copy=rgb2gray(copy);
copy=double(copy);
h=histo(copy,2);
figure,plot(h);
oo = 1/7*ones(1,7);
v = conv(h,oo);

figure,plot(v);

[maxtab, mintab]=peakdet1(v, 0.005);
k = length(maxtab)



[mask,mu,v,p]=EMSeg(copy,k);
se = strel('disk',1);
mask1=imclose(mask,se);

[mu,mask]=kmeans(copy,k);
se = strel('disk',1);
mask2=imclose(mask,se);
% 
figure; imagesc(mask1),colormap(gray(256)),axis image;
 figure; imagesc(mask2),colormap(gray(256)),axis image;
