資源簡(jiǎn)介
分水嶺分割圖像方法,有詳細(xì)注釋?zhuān)档脫碛?
代碼片段和文件信息
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);%直接應(yīng)用分水嶺算法
Lrgb=label2rgb(L);%轉(zhuǎn)化為彩色圖像
figureimshow(Lrgb);%顯示分割后的圖像
title(‘Watershed?transform?of?gradient?magnitude?(Lrgb)‘);
se=strel(‘disk‘2);%圓形結(jié)構(gòu)元素
Io=imopen(Ise);%形態(tài)學(xué)開(kāi)操作
figuresubplot(121);
imshow(Io);%顯示執(zhí)行開(kāi)操作后的圖像
title(‘Opening?(Io)‘)
Ie=imrode(Ise);%對(duì)圖像進(jìn)行腐蝕
Iobr=imreconstruct(IeI);%形態(tài)學(xué)重建
subplot(122)imshow(Iobr);%顯示重建后的圖像
title(‘Opening-by-reconstruction?(Iobr)‘)
Ioc=imclose(Iose);%形態(tài)學(xué)操作
figuresubplot(121)
imshow(Ioc)%顯示關(guān)操作后的圖像
title(‘Opening-closeing?(Ioc)‘)
Iobrd=imdila
- 上一篇:dwa動(dòng)態(tài)窗口算法代碼
- 下一篇:QAM16.m
評(píng)論
共有 條評(píng)論