資源簡(jiǎn)介
亞像素邊緣提取、matlab代碼。文檔里包括插值法、擬合法、基于灰度矩法、基于zernike矩法

代碼片段和文件信息
clear
clc
II=imread(‘1.bmp‘);
II=rgb2gray(II);
II=im2bw(II0.25);
%?II=medfilt2(II);
figure(1)imshow(II)
I=double(II);
[mn]=size(I);
%用Canny算子進(jìn)行像素邊緣檢測(cè),判別閾值為0.1
ff=edge(I‘canny‘0.1);
figure(2)imshow(ff)
t1=clock;
tic;
f=double(ff);
%求原函數(shù)梯度函數(shù)
R=zeros(mn);
for?xi=2:1:m-1
????for?yi=2:1:n-1
????????R(xiyi)=abs(I(xi+1yi+1)+2*I(xiyi+1)+I(xi-1yi+1)-I(xi-1yi-1)-2*I(xiyi-1)-I(xi+1yi-1))+abs(I(xi-1yi-1)+2*I(xi-1yi)+I(xi-1yi+1)-I(xi+1yi+1)-2*I(xi+1yi)-I(xi+1yi-1));
????end
end
%開始求坐標(biāo)
figure(4)imshow(R)
nn=1;
W=zeros(mn);
for?x=2:1:m-1
????for?y=2:1:n-1
????????if?f(xy)==0
???????????W(xy)=0;
????????else
????????????i=[R(x-1y)R(xy)R(x+1y)];
????????????j=[R(xy-1)R(xy)R(xy+1)];
????????????if?((?(i(2)>i(1))||(i(2)>i(3))?)||(?(j(2)>j(1))||(j(2)>j(3))?))
????????????????Xe=x+(i(1)-i(3))/((i(1)-2*i(2)+i(3))+eps);%求亞像素邊緣坐標(biāo)[XeYe]
????????????????Ye=y+(j(1)-j(3))/((j(1)-2*j(2)+j(3))+eps);
????????????????if?(Xe0)&(Ye0)
????????????????????Xe1(nn)=Xe;???????????????????????????%得到的亞像素邊緣點(diǎn)
????????????????????Ye1(nn)=Ye;
????????????????????Xe2(nn)=round(Xe);????????????????????%得到的逼近的邊緣點(diǎn)
????????????????????Ye2(nn)=round(Ye);
????????????????????W(Xe2(nn)Ye2(nn))=1;?????????????????%把檢測(cè)到的邊緣點(diǎn)直觀的表示出來(lái)
????????????????????nn=nn+1;??????????????????????????????
????????????????end
????????????end
????????end
????end
end
toc;
t2=clock;
etime(t2t1);
figure(3)imshow(W)
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-08-16?11:51??subpixel?edge?detection\
?????文件??????152694??2016-08-16?09:31??subpixel?edge?detection\1.bmp
?????文件???????74970??2016-08-08?21:07??subpixel?edge?detection\12.bmp
?????文件??????921654??2016-05-27?20:19??subpixel?edge?detection\4.bmp
?????文件??????921654??2016-05-27?20:19??subpixel?edge?detection\5.bmp
?????文件??????363662??2016-07-12?15:28??subpixel?edge?detection\6.bmp
?????文件????????5401??2016-08-08?21:13??subpixel?edge?detection\Improvezernike7.m
?????文件????????1538??2016-08-16?09:41??subpixel?edge?detection\chazhi.m
?????文件????????6587??2016-08-16?11:36??subpixel?edge?detection\grayju.m
?????文件????????2575??2016-08-16?10:24??subpixel?edge?detection\nihe.m
?????文件????????2805??2016-08-16?11:50??subpixel?edge?detection\zernike7.m
評(píng)論
共有 條評(píng)論