宁铃果果 发表于 2010-1-9 15:01

f=imread('rice.bmp');
subplot(2,2,1)
imshow(f);
title('(a)原始图像');
f=double(f);
%计算距离函数
hv=fspecial('prewit');
hh=hv.';
gv=abs(imfilter(f,hv,'replicate'));
gh=abs(imfilter(f,hh,'replicate'));
g=sqrt(gv.^2+gh.^2);
%watershed算法分割
subplot(2,2,2);
L=watershed(g);
wr=L==0;
imshow(wr);
title('(b)分水岭');
f(wr)=255;
subplot(2,2,3);
imshow(uint8(f));
title('(c)分割结果');
%取出梯度图中局部极小值点
re=imregionalmin(g);
subplot(2,2,4);
title('(d)局部极小值');

这是分水岭算法MATLAB程序,我自己运行了一下,但是有两句话有问题,小女子属于初学,对这实在是搞不懂,请教各位大侠!
页: [1]
查看完整版本: 分水岭分割程序,问题请教