• 大小: 673KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-27
  • 语言: Matlab
  • 标签: subpixel  

资源简介

亚像素边缘提取、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算子进行像素边缘检测,判别阈值为0.1
ff=edge(I‘canny‘0.1);
figure(2)imshow(ff)
t1=clock;
tic;
f=double(ff);
%求原函数梯度函数
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
%开始求坐标
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);%求亚像素边缘坐标[XeYe]
                Ye=y+(j(1)-j(3))/((j(1)-2*j(2)+j(3))+eps);
                if (Xe0)&(Ye0)
                    Xe1(nn)=Xe;                           %得到的亚像素边缘点
                    Ye1(nn)=Ye;
                    Xe2(nn)=round(Xe);                    %得到的逼近的边缘点
                    Ye2(nn)=round(Ye);
                    W(Xe2(nn)Ye2(nn))=1;                 %把检测到的边缘点直观的表示出来
                    nn=nn+1;                              
                end
            end
        end
    end
end
toc;
t2=clock;
etime(t2t1);
figure(3)imshow(W)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           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

评论

共有 条评论

相关资源