程序图像边缘提取算法研究_第1页
程序图像边缘提取算法研究_第2页
程序图像边缘提取算法研究_第3页
程序图像边缘提取算法研究_第4页
程序图像边缘提取算法研究_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

图像边缘提取算法研究报告概述图像的边缘包含了图像最重要的信息。什么是边缘?一般是指图像灰度变化率最大的位置。从成因上看,一般图像边缘主要由四个方面的因素形成:(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 的位置坐标 ),(|),(hnmTfSh(而采用二阶微分算子情形,一般是对某个阈值 确立0),(|),(fh(4) 对集合 进行整理,同时调整阈值 h。hSRoberts 算子Roberts 算子是一种利用局部差分算子寻找边缘的算子,两个模板分别为10xR01yR则, =),(jifRx ),(,jifjif=y)1算法的步骤为:(1) 首先用两个模板分别对图像作用得到 和 ;fRxfy(2) 对 ,进行阈值判决,若 大于阈值则相应的2),(yxRjiTf ),(jiT点位于便于边缘处。对于阈值选取的说明:由于微分算子的检测性能受阈值的影响较大,为此,针对具体图像我们采用以下阈值的选取方法,对处理后的图像统计大于某一阈值的点,对这些数据求平均值,以下每个程序均采用此方法,不再做说明。具体程序如下:%-filename:Roberts.m-%-Useage:edge detecting by the Roberts operator-%-Writer: Subailong-function edgeRb=Roberts(oimage);xlen ylen = size(oimage); %read the sizeedgeX = zeros(xlen,ylen); %horizontal directionedgeY = zeros(xlen,ylen); %vertical directionedgeXY = zeros(xlen,ylen); %synthesize the two directions%-process the oringin image with the operator-for i = 1:xlen-1for j = 1:ylen-1edgeX(i,j) = oimage(i,j) - oimage(i+1,j+1);edgeY(i,j) = oimage(i+1,j) - oimage(i,j+1);endendedgeX = abs(edgeX);edgeY = abs(edgeY);edgeXY = sqrt(edgeX.*edgeX + edgeY.*edgeY);%-Thresh estimate-rsum=0;counter=0;for i = 2:xlen-1for j = 2:ylen-1 if(edgeXY(i,j)15)rsum=rsum+edgeXY(i,j);counter=counter+1;endendendthreshold=rsum/counter; %threshold = 2*sum(sum(edgeXY(1:xlen-1,1:ylen-1)/(xlen-1)*(ylen-1);%-edge detecting-for i = 1:xlen-1for j = 1:ylen-1if (edgeXY(i,j)threshold)edgeimage(i,j) = 255;elseedgeimage(i,j) = 0;endendendedgeRb = edgeimage;Sobel 算子Sobel 算子采用中心差分,但对中间水平线和垂直线上的四个邻近点赋予略高的权重。两个模板分别如下:102xS120yS该算法的处理过程同 Roberts 算字,在这个程序中,我们采用两个方向分别进行阈值判断,程序如下:%-filename:Sobel.m-%-Useage:edge detecting by the Sobel operator-%-Writer: Subailong-function edgeS=Sobel(oimage);xlen ylen = size(oimage); %read the sizeedgeX = zeros(xlen,ylen); %horizontal directionedgeY = zeros(xlen,ylen); %vertical directionedgeXY = zeros(xlen,ylen); %synthesize the two directionsd= zeros(xlen,ylen); %direction of the conresponding pointsedgeimage= zeros(xlen,ylen); %the result imageH1 = -1 0 1;-2 0 2;-1 0 1; %horizontal operatorH2 = -1 -2 -1;0 0 0;1 2 1; %vertical operator%-process the oringin image with the operator-for i = 1:xlenfor j = 1:ylenfor m = 1:3for n = 1:3updateX = i-m+2;updateY = j-n+2;if (updateX=1) %save the directionelsed(i,j)=2; %save the directionend endendendendend%edgeX = abs(edgeX);%edgeY = abs(edgeY);%edgeXY = sqrt(edgeX.*edgeX + edgeY.*edgeY);%-Thresh estimate-rsum=0;counter=0;for i = 2:xlen-1for j = 2:ylen-1 if(edgeX(i,j)20)rsum=rsum+edgeX(i,j);counter=counter+1;endendendthreshold=rsum/counter; %threshold = 4*sum(sum(edgeXY(2:xlen-1,2:ylen-1)/(xlen-2)*(ylen-2);%-edge detecting-for i = 2:xlen-1for j = 2:ylen-1if (d(i,j)=1elseif (d(i,j)=2endendendedgeS=edgeimage;Prewitt 算子 Prewitt算子也属于中心差分类型,但没有给最邻近点较高的权重,两个模板如下:10xP10yP该算法的处理过程同 Roberts 算字,在这个程序中,我们采用两个方向分别进行阈值判断,程序如下: %-filename:Prewitt.m-%-Useage:edge detecting by the Prewitt operator-%-Writer: Subailong-function edgeP=Prewitt(oimage);xlen ylen = size(oimage); %read the sizeedgeX = zeros(xlen,ylen); %horizontal directionedgeY = zeros(xlen,ylen); %vertical directionedgeXY = zeros(xlen,ylen); %synthesize the two directionsedgeimage = zeros(xlen,ylen); %the result imaged=zeros(xlen,ylen); %direction of the conresponding pointsH1 = -1 0 1;-1 0 1;-1 0 1; %horizontal operatorH2 = 1 1 1;0 0 0;-1 -1 -1; %vertical operator%-process the oringin image with the operator-for i = 1:xlenfor j = 1:ylenfor m = 1:3for n = 1:3updateX = i-m+2;updateY = j-n+2;if (updateX=1) %save the directionelsed(i,j)=2; %save the directionendendendendendend%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);%-%-Thresh estimate-rsum=0;counter=0;for i = 2:xlen-1for j = 2:ylen-1 if(edgeX(i,j)15)rsum=rsum+edgeX(i,j);counter=counter+1;endendendthreshold=rsum/counter; %-edge detecting-for i = 2:xlen-1for j = 2:ylen-1if (d(i,j)=1elseif (d(i,j)=2endendendedgeP=edgeimage;Krisch 算子Krisch 算子采用以下 8 种形式的模板:, , ,305NK350NEK530EK, , ,5SE 5S SW,30WK30NWK图像中的每个位置都要经过 8 个模板的作用,最大值被选作输出,达到最大值的方向就是边缘的方向。实际上可采用以下快速算法: 74321 7,10:35max,),(kkk kaats tsjim 其 中具体程序如下:%-filename:Kirsch.m-%-Useage:edge detecting by the Kirsch operator-%-Writer: Subailong-function edgeK=Kirsch(oimage);xlen ylen = size(oimage); %read the sizeedge = zeros(xlen,ylen); %the result imaged = zeros(xlen,ylen); %direction of the conresponding points%define three voriables to computer fastK = zeros(8,1);t = zeros(8,1);f = zeros(8,1);%-process the oringin image with the operator-for i = 2:xlen-1for j = 2:ylen-1temp = 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); %NorthK(2) = oimage(i-1,j)+oimage(i-1,j+1)+oimage(i,j+1); %NortheastK(3) = oimage(i-1,j+1)+oimage(i,j+1)+oimage(i+1,j+1); %EastK(4) = oimage(i,j+1)+oimage(i+1,j+1)+oimage(i+1,j); %SoutheastK(5) = oimage(i+1,j+1)+oimage(i+1,j)+oimage(i+1,j-1); %SouthK(6) = oimage(i+1,j)+oimage(i+1,j-1)+oimage(i,j-1); %SouthweastK(7) = oimage(i+1,j-1)+oimage(i,j-1)+oimage(i-1,j-1); %WeastK(8) = oimage(i,j-1)+oimage(i-1,j-1)+oimage(i-1,j); %NorthWestfor m = 1:8t(m) = temp-K(m);endf=abs(5*K-3*t);m c=max(f);edge(i,j)=m; %save the maximum d(i,j)=c; %save the direction of maximumendend%-Thresh estimate-rsum=0;counter=0;for i = 2:xlen-1for j = 2:ylen-1 if(edge(i,j)200)rsum=rsum+edge(i,j);counter=counter+1;endendendthreshold=rsum/counter;%-edge detecting- for i = 2:xlen-1for j = 2:ylen-1if (d(i,j)=1)elseif (d(i,j)=2)elseif (d(i,j)=3)elseif (d(i,j)=4)elseif (d(i,j)=5)elseif (d(i,j)=6)elseif (d(i,j)=7)elseif (d(i,j)=8)endendendedgeK=edgeimage;Robinson 算子Robinson 算子也采用 8 形式的模板,其具体形式参加课本(课本中第一个算子有误) ,这里需要说明一下 Robinson 算子的特征,每个四个其相应元素的负号相反,就是说在计算中只需计算四个就行了。在本程序中为了比较数值(而不是绝对值,这样更好地体现方向性)的大小,仍计算 8 个。具体程序如下:%-filename:Robinson.m-%-Useage:edge detecting by the Robinson operator-%-Writer: by Subailong-function edgeR=Robinson(oimage);xlen ylen = size(oimage); %read the sizeedgeRobinson = zeros(xlen,ylen); edgeRobinsonimage = zeros(xlen,ylen); %the result imaged=zeros(xlen,ylen); %directi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论