資源簡介
分水嶺分割圖像方法,有詳細注釋,值得擁有
代碼片段和文件信息
I=imread(‘T_23_N.bmp‘);??%讀取原圖像
figuresubplot(121)%顯示灰度圖像
imshow(I)
hy=fspecial(‘sobel‘);%sobel算子
hx=hy‘;
Iy=imfilter(double(I)hy‘replicate‘);%濾波求y方向邊緣
Ix=imfilter(double(I)hx‘replicate‘);%濾除x方向邊緣
gradmag=sqrt(Ix.^2+Iy.^2);%求模
subplot(122);imshow(gradmag[])%顯示梯度
title(‘Gradient?magnitude?()gradmag‘);
L=watershed(gradmag);%直接應用分水嶺算法
Lrgb=label2rgb(L);%轉化為彩色圖像
figureimshow(Lrgb);%顯示分割后的圖像
title(‘Watershed?transform?of?gradient?magnitude?(Lrgb)‘);
se=strel(‘disk‘2);%圓形結構元素
Io=imopen(Ise);%形態(tài)學開操作
figuresubplot(121);
imshow(Io);%顯示執(zhí)行開操作后的圖像
title(‘Opening?(Io)‘)
Ie=imrode(Ise);%對圖像進行腐蝕
Iobr=imreconstruct(IeI);%形態(tài)學重建
subplot(122)imshow(Iobr);%顯示重建后的圖像
title(‘Opening-by-reconstruction?(Iobr)‘)
Ioc=imclose(Iose);%形態(tài)學操作
figuresubplot(121)
imshow(Ioc)%顯示關操作后的圖像
title(‘Opening-closeing?(Ioc)‘)
Iobrd=imdila
- 上一篇:dwa動態(tài)窗口算法代碼
- 下一篇:QAM16.m
評論
共有 條評論