图像边缘提取算法研究报告.docx

上传人:b****3 文档编号:4869245 上传时间:2022-12-11 格式:DOCX 页数:35 大小:348.60KB
下载 相关 举报
图像边缘提取算法研究报告.docx_第1页
第1页 / 共35页
图像边缘提取算法研究报告.docx_第2页
第2页 / 共35页
图像边缘提取算法研究报告.docx_第3页
第3页 / 共35页
图像边缘提取算法研究报告.docx_第4页
第4页 / 共35页
图像边缘提取算法研究报告.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

图像边缘提取算法研究报告.docx

《图像边缘提取算法研究报告.docx》由会员分享,可在线阅读,更多相关《图像边缘提取算法研究报告.docx(35页珍藏版)》请在冰豆网上搜索。

图像边缘提取算法研究报告.docx

图像边缘提取算法研究报告

图像边缘提取算法研究报告

概述

图像的边缘包含了图像最重要的信息。

什么是边缘?

一般是指图像灰度变化率最大的位置。

从成因上看,一般图像边缘主要由四个方面的因素形成:

(1)图像灰度在表面法向变化的不连续造成的边缘;

(2)图像对像素在空间上不一致形成的边缘;(3)在光滑的表面上由于颜色的不一致形成的边缘:

(4)物体的光影造成的边缘。

图像边缘提取的作用有:

(1)改良图像质量;

(2)分离对象;(3)理解和重构视觉场景;(4)识别特征;(5)其他。

图像边缘检测是图像处理与计算机视觉共同的基本课题,1960年以来,相继发展了一系列采用梯度算子和拉普拉斯算子的边缘检测技术;为了降低图像噪声对边缘检测算法的干扰,1980年以来,又建立了高斯低通滤波与拉普拉斯算子复合的过零点检测Marr-Hildreth理论;在另一个方向上,1980年代初期,Canny从信号处理的角度出发,使边缘检测算法更具有实用性。

本报告主要介绍以上以上几个方面的内容,通过matlab程序实现以上几种算法,对比各种算法的性能。

算法介绍及相应程序

一、基于微分算子的边缘检测

检测图像边缘信息,可以把图像看做曲面,边缘就是图像的变化最剧烈的位置。

这里所讲的边缘信息包含两个方面:

一是边缘的具体位置,即像素的坐标;而是边缘的方向。

微分算子有两个重要性质:

定域性(或局部性)、敏感性(或无界性)。

敏感性就是说,它对局部的函数值变化很敏感,但是因其对变化过于敏感又有了天然的缺陷——不能抵抗噪声。

局部性意思是指,每一点的导数只与函数在该点邻近的信息有关。

主要有两大类基于微分算子的边缘检测技术:

一阶微分算子边缘检测与二阶微分算子边缘检测。

这些检测技术采用以下的基本步骤:

(1)将相应的微分算子简化为离散的差分格式,进而简化为模板(记为T)。

(2)利用模板对图像f(m,n)进行运算,获得模板作用后的结果Tf(m,n)。

(3)提出阈值h,在采用一阶微分算子情形记录下高于某个阈值h的位置坐标

(而采用二阶微分算子情形,一般是对某个阈值

确立

(4)对集合

进行整理,同时调整阈值h。

Roberts算子

Roberts算子是一种利用局部差分算子寻找边缘的算子,两个模板分别为

则,

=

=

算法的步骤为:

(1)首先用两个模板分别对图像作用得到

(2)对

,进行阈值判决,若

大于阈值则相应的点

位于便于边缘处。

对于阈值选取的说明:

由于微分算子的检测性能受阈值的影响较大,为此,针对具体图像我们采用以下阈值的选取方法,对处理后的图像统计大于某一阈值的点,对这些数据求平均值,以下每个程序均采用此方法,不再做说明。

具体程序如下:

%-----filename:

Roberts.m-------------------------

%-----Useage:

edgedetectingbytheRobertsoperator-----

%-----Writer:

Subailong-------------------------

functionedgeRb=Roberts(oimage);

[xlenylen]=size(oimage);%readthesize

edgeX=zeros(xlen,ylen);%horizontaldirection

edgeY=zeros(xlen,ylen);%verticaldirection

edgeXY=zeros(xlen,ylen);%synthesizethetwodirections

%--------------processtheoringinimagewiththeoperator----------------

fori=1:

xlen-1

forj=1:

ylen-1

edgeX(i,j)=oimage(i,j)-oimage(i+1,j+1);

edgeY(i,j)=oimage(i+1,j)-oimage(i,j+1);

end

end

edgeX=abs(edgeX);

edgeY=abs(edgeY);

edgeXY=sqrt(edgeX.*edgeX+edgeY.*edgeY);

%---------Threshestimate--------------------

rsum=0;

counter=0;

fori=2:

xlen-1

forj=2:

ylen-1

if(edgeXY(i,j)>15)

rsum=rsum+edgeXY(i,j);

counter=counter+1;

end

end

end

threshold=rsum/counter;

%threshold=2*sum(sum(edgeXY(1:

xlen-1,1:

ylen-1)))/((xlen-1)*(ylen-1));

%-------edgedetecting---------------

fori=1:

xlen-1

forj=1:

ylen-1

if(edgeXY(i,j)>threshold)

edgeimage(i,j)=255;

else

edgeimage(i,j)=0;

end

end

end

edgeRb=edgeimage;

Sobel算子

Sobel算子采用中心差分,但对中间水平线和垂直线上的四个邻近点赋予略高的权重。

两个模板分别如下:

该算法的处理过程同Roberts算字,在这个程序中,我们采用两个方向分别进行阈值判断,程序如下:

%-----filename:

Sobel.m-------------------------

%-----Useage:

edgedetectingbytheSobeloperator-----

%-----Writer:

Subailong-------------------------

functionedgeS=Sobel(oimage);

[xlenylen]=size(oimage);%readthesize

edgeX=zeros(xlen,ylen);%horizontaldirection

edgeY=zeros(xlen,ylen);%verticaldirection

edgeXY=zeros(xlen,ylen);%synthesizethetwodirections

d=zeros(xlen,ylen);%directionoftheconrespondingpoints

edgeimage=zeros(xlen,ylen);%theresultimage

H1=[-101;-202;-101];%horizontaloperator

H2=[-1-2-1;000;121];%verticaloperator

%--------------processtheoringinimagewiththeoperator----------------

fori=1:

xlen

forj=1:

ylen

form=1:

3

forn=1:

3

updateX=i-m+2;

updateY=j-n+2;

if((updateX>=1)&&(updateX<=xlen)&&(updateY>=1)&&(updateY<=ylen))

edgeX(i,j)=edgeX(i,j)+H1(m,n)*oimage(updateX,updateY);%processtheoringinimagewithH1operator

edgeY(i,j)=edgeY(i,j)+H2(m,n)*oimage(updateX,updateY);%processtheoringinimagewithH1operator

ifedgeX(i,j)>edgeY(i,j)

d(i,j)=1;%savethedirection

else

d(i,j)=2;%savethedirection

end

end

end

end

end

end

%edgeX=abs(edgeX);

%edgeY=abs(edgeY);

%edgeXY=sqrt(edgeX.*edgeX+edgeY.*edgeY);

%---------Threshestimate--------------------

rsum=0;

counter=0;

fori=2:

xlen-1

forj=2:

ylen-1

if(edgeX(i,j)>20)

rsum=rsum+edgeX(i,j);

counter=counter+1;

end

end

end

threshold=rsum/counter;

%threshold=4*sum(sum(edgeXY(2:

xlen-1,2:

ylen-1)))/((xlen-2)*(ylen-2));

%-------edgedetecting---------------

fori=2:

xlen-1

forj=2:

ylen-1

if(d(i,j)==1&&edgeX(i,j)>edgeX(i,j+1)&&edgeX(i,j)>edgeX(i,j-1)&&edgeX(i,j)>threshold)

edgeimage(i,j)=1;

elseif(d(i,j)==2&&edgeY(i,j)>edgeY(i+1,j)&&(edgeY(i,j)>edgeY(i-1,j))&&edgeY(i,j)>threshold)

edgeimage(i,j)=1;

end

end

end

edgeS=edgeimage;

Prewitt算子

Prewitt算子也属于中心差分类型,但没有给最邻近点较高的权重,两个模板如下:

该算法的处理过程同Roberts算字,在这个程序中,我们采用两个方向分别进行阈值判断,程序如下:

%-----filename:

Prewitt.m-------------------------

%-----Useage:

edgedetectingbythePrewittoperator-----

%-----Writer:

Subailong-------------------------

functionedgeP=Prewitt(oimage);

[xlenylen]=size(oimage);%readthesize

edgeX=zeros(xlen,ylen);%horizontaldirection

edgeY=zeros(xlen,ylen);%verticaldirection

edgeXY=zeros(xlen,ylen);%synthesizethetwodirections

edgeimage=zeros(xlen,ylen);%theresultimage

d=zeros(xlen,ylen);%directionoftheconrespondingpoints

H1=[-101;-101;-101];%horizontaloperator

H2=[111;000;-1-1-1];%verticaloperator

%--------------processtheoringinimagewiththeoperator----------------

fori=1:

xlen

forj=1:

ylen

form=1:

3

forn=1:

3

updateX=i-m+2;

updateY=j-n+2;

if((updateX>=1)&&(updateX<=xlen)&&(updateY>=1)&&(updateY<=ylen))

edgeX(i,j)=edgeX(i,j)+H1(m,n)*oimage(updateX,updateY);%processtheoringinimagewithH1operator

edgeY(i,j)=edgeY(i,j)+H2(m,n)*oimage(updateX,updateY);%processtheoringinimagewithH1operator

ifedgeX(i,j)>edgeY(i,j)

d(i,j)=1;%savethedirection

else

d(i,j)=2;%savethedirection

end

end

end

end

end

end

%edgeX=abs(edgeX);

%edgeY=abs(edgeY);

%edgeXY=edgeX.*edgeX+edgeY.*edgeY;

%threshold=4*sum(sum(edgeXY(2:

xlen-1,2:

ylen-1)))/((xlen-2)*(ylen-2));

%-------------------------------------------

%---------Threshestimate--------------------

rsum=0;

counter=0;

fori=2:

xlen-1

forj=2:

ylen-1

if(edgeX(i,j)>15)

rsum=rsum+edgeX(i,j);

counter=counter+1;

end

end

end

threshold=rsum/counter;

%-------edgedetecting---------------

fori=2:

xlen-1

forj=2:

ylen-1

if(d(i,j)==1&&edgeX(i,j)>edgeX(i,j+1)&&edgeX(i,j)>edgeX(i,j-1)&&edgeX(i,j)>threshold)

edgeimage(i,j)=1;

elseif(d(i,j)==2&&edgeY(i,j)>edgeY(i+1,j)&&(edgeY(i,j)>edgeY(i-1,j))&&edgeY(i,j)>threshold)

edgeimage(i,j)=1;

end

end

end

edgeP=edgeimage;

Krisch算子

Krisch算子采用以下8种形式的模板:

图像中的每个位置都要经过8个模板的作用,最大值被选作输出,达到最大值的方向就是边缘的方向。

实际上可采用以下快速算法:

 

具体程序如下:

%-----filename:

Kirsch.m-------------------------

%-----Useage:

edgedetectingbytheKirschoperator-----

%-----Writer:

Subailong-------------------------

functionedgeK=Kirsch(oimage);

[xlenylen]=size(oimage);%readthesize

edge=zeros(xlen,ylen);%theresultimage

d=zeros(xlen,ylen);%directionoftheconrespondingpoints

%definethreevoriablestocomputerfast

K=zeros(8,1);

t=zeros(8,1);

f=zeros(8,1);

%--------------processtheoringinimagewiththeoperator----------------

fori=2:

xlen-1

forj=2:

ylen-1

temp=sum(sum(oimage([i-1:

i+1],[j-1:

j+1])))-oimage(i,j);

K

(1)=oimage(i-1,j-1)+oimage(i-1,j)+oimage(i-1,j+1);%North

K

(2)=oimage(i-1,j)+oimage(i-1,j+1)+oimage(i,j+1);%Northeast

K(3)=oimage(i-1,j+1)+oimage(i,j+1)+oimage(i+1,j+1);%East

K(4)=oimage(i,j+1)+oimage(i+1,j+1)+oimage(i+1,j);%Southeast

K(5)=oimage(i+1,j+1)+oimage(i+1,j)+oimage(i+1,j-1);%South

K(6)=oimage(i+1,j)+oimage(i+1,j-1)+oimage(i,j-1);%Southweast

K(7)=oimage(i+1,j-1)+oimage(i,j-1)+oimage(i-1,j-1);%Weast

K(8)=oimage(i,j-1)+oimage(i-1,j-1)+oimage(i-1,j);%NorthWest

form=1:

8

t(m)=temp-K(m);

end

f=abs(5*K-3*t);

[mc]=max(f);

edge(i,j)=m;%savethemaximum

d(i,j)=c;%savethedirectionofmaximum

end

end

%-----Threshestimate-------------------------------

rsum=0;

counter=0;

fori=2:

xlen-1

forj=2:

ylen-1

if(edge(i,j)>200)

rsum=rsum+edge(i,j);

counter=counter+1;

end

end

end

threshold=rsum/counter;

%-----------edgedetecting-----------------------

fori=2:

xlen-1

forj=2:

ylen-1

if(d(i,j)==1)&&(edge(i,j)>edge(i-1,j))&&(edge(i,j)>threshold)

edgeimage(i,j)=255;

elseif(d(i,j)==2)&&(edge(i,j)>edge(i-1,j+1))&&(edge(i,j)>threshold)

edgeimage(i,j)=255;

elseif(d(i,j)==3)&&(edge(i,j)>edge(i,j+1))&&(edge(i,j)>threshold)

edgeimage(i,j)=255;

elseif(d(i,j)==4)&&(edge(i,j)>edge(i+1,j+1))&&(edge(i,j)>threshold)

edgeimage(i,j)=255;

elseif(d(i,j)==5)&&(edge(i,j)>edge(i+1,j))&&(edge(i,j)>threshold)

edgeimage(i,j)=255;

elseif(d(i,j)==6)&&(edge(i,j)>edge(i+1,j-1))&&(edge(i,j)>threshold)

edgeimage(i,j)=255;

elseif(d(i,j)==7)&&(edge(i,j)>edge(i,j-1))&&(edge(i,j)>threshold)

edgeimage(i,j)=255;

elseif(d(i,j)==8)&&(edge(i,j)>edge(i-1,j-1))&&(edge(i,j)>threshold)

edgeimage(i,j)=255;

end

end

end

edgeK=edgeimage;

Robinson算子

Robinson算子也采用8形式的模板,其具体形式参加课本(课本中第一个算子有误),这里需要说明一下Robinson算子的特征,每个四个其相应元素的负号相反,就是说在计算中只需计算四个就行了。

在本程序中为了比较数值(而不是绝对值,这样更好地体现方向性)的大小,仍计算8个。

具体程序如下:

%-----filename:

Robinson.m-------------------------

%-----Useage:

edgedetectingbytheRobinsonoperator-----

%-----Writer:

bySubailong-------------------------

functionedgeR=Robinson(oimage);

[xlenylen]=size(oimage);%readthesize

edgeRobinson=zeros(xlen,ylen);

edgeRobinsonimage=zeros(xlen,ylen);%theresultimage

d=zeros(xlen,ylen);%directionoftheconrespondingpoints

%--------------processtheoringinimagewiththeoperator----------------

R=zeros(4,1);

fori=2:

xlen-1

forj=2:

ylen-1

R

(1)=oimage(i-1,j-1)+oimage(i-1,j+1)-oimage(i+1,j+1)-oimage(i+1,j-1)...

+oimage(i-1,j)-oimage(i+1,j)+oimage(i-1,j)-oimage(i+1,j);%North

R

(2)=oimage(i-1,j)+oimage(i,j+1)-oimage(i+1,j)-oimage(i,j-1)...

+oimage(i-1,j+1)-oimage(i+1,j-1)+oimage(i-1,j+1)-oimage(i+1,j-1);%Northeast

R(3)=oimage(i-1,j+1

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1