www.pudn.com > watershed.rar > watershed3.m, change:2012-05-19,size:359b


f=imread('baboon.gif'); 
h=fspecial('sobel'); 
fd=double(f); 
g=sqrt(imfilter(fd,h,'replicate').^2+... 
       imfilter(fd,h','replicate').^2); 
L=watershed(g); 
wr=L==0; 
rm=imregionalmin(g); 
im=imextendedmin(f,2); 
fim=f; 
fim(im)=175; 
Lim=watershed(bwdist(im)); 
em=Lim==0; 
g2=imimposemin(g,im|em); 
L2=watershed(g2); 
f2=f; 
f2(L2==0)=255; 
imshow(f2);