SUSAN算子特征点检测实验报告_第1页
SUSAN算子特征点检测实验报告_第2页
SUSAN算子特征点检测实验报告_第3页
SUSAN算子特征点检测实验报告_第4页
SUSAN算子特征点检测实验报告_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

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

文档简介

1、机器视觉实验(3)一、实验介绍特征点:即图像的极值点、线段的端点、曲线曲率最大点,是图像的重要特征,对图像处理与分析具有重要作用。特征点保留了图像的重要特征,可以代替图像的处理,有效减少数据量,提高处理速度。特征点检测:从图像中检测和提取特征点的过程和算法。检测方法有基于梯度的检测方法,基于模板的检测方法,基于梯度和模板的检测方法。比较常用的算子有SUSAN、Harris、Moravec、Foerstner、FAST、SIFT等角点检测算子。二、实验内容1、SUSAN算子SUSAN算子是牛津大学的smith教授提出的,只使用一个圆形模板来计算各向同性的响应,既可检测目标边缘点,又能检测图像中的

2、角点,且具有较强的鲁棒性。(1) 基本思想 SUSAN准则的原理如图所示,用一个圆形模板遍历图像,若模板内其他任意像素的灰度值与模板中心像素(核)的灰度值的差小于一定阈值,就认为该点与核具有相同(或相近)的灰度值,满足这样条件的像素组成的区域称为核值相似区(Univalue Segment Assimilating Nucleus, USAN)。把图像中的每个像素与具有相近灰度值的局部区域相联系是SUSAN准则的基础。(2)基本步骤 第一步:选择圆形模板,计算相似度。 a、圆形模板如图所示,共37个像素。 b、相似度 第二步:确定USAN区域。 第三步:阈值化得到初步的边缘响应。 G的取值为U

3、SAN最大值的1/2。USAN值越小,角点的响应就越强。 第四步:可选择性进行非极大值抑制,角点特征就得到全部增强。2、实验程序 BOOL CBmpProcessView:Susan(LPSTR lpDIBBits, LONG lWidth, LONG lHeight)/ 指向源图像的指针LPSTRlpSrc;/ 指向缓存图像的指针LPSTRlpDst;/ 指向缓存DIB图像的指针LPSTRlpNewDIBBits;HLOCALhNewDIBBits;/循环变量long i;long j;/像素值int x,r,n=0;unsigned char pixel37;/ 暂时分配内存,以保存新图像

4、hNewDIBBits = LocalAlloc(LHND, lWidth * lHeight);if (hNewDIBBits = NULL)/ 分配内存失败return FALSE;/ 锁定内存lpNewDIBBits = (char * )LocalLock(hNewDIBBits);/ 初始化新分配的内存,设定初始值为255lpDst = (char *)lpNewDIBBits;memset(lpDst, (BYTE)255, lWidth * lHeight);POINT pointxy;/定义一个POINT型数据 corner.clear();/使用水平方向的结构元素进行腐蚀fo

5、r(j = lHeight-3; j=2; j-)for(i = 2;i lWidth-2; i+)/ 指向源图像第j行,第i个象素的指针lpSrc = (char *)lpDIBBits + lWidth * j + i;/ 指向目标图像第j行,第i个象素的指针lpDst = (char *)lpNewDIBBits + lWidth * j + i;/取得当前指针处7*7区域的像素值,注意要转换为unsigned char型pixel0 = (unsigned char)*(lpSrc - 3 * lWidth - 1);pixel1 = (unsigned char)*(lpSrc -

6、3 * lWidth );pixel2 = (unsigned char)*(lpSrc - 3 * lWidth + 1);pixel3 = (unsigned char)*(lpSrc - 2 * lWidth + 2);pixel4 = (unsigned char)*(lpSrc - lWidth + 3);pixel5 = (unsigned char)*(lpSrc + 3);pixel6 = (unsigned char)*(lpSrc + lWidth + 3);pixel7 = (unsigned char)*(lpSrc + 2 * lWidth + 2);pixel8 =

7、 (unsigned char)*(lpSrc + 3 * lWidth + 1);pixel9 = (unsigned char)*(lpSrc + 3 * lWidth);pixel10 = (unsigned char)*(lpSrc + 3 * lWidth - 1);pixel11 = (unsigned char)*(lpSrc + 2 * lWidth - 2);pixel12 = (unsigned char)*(lpSrc + lWidth - 3);pixel13 = (unsigned char)*(lpSrc - 3);pixel14 = (unsigned char)

8、*(lpSrc - lWidth - 3);pixel15 = (unsigned char)*(lpSrc - 2 * lWidth - 2);pixel16 = (unsigned char)*(lpSrc - 2 * lWidth - 1);pixel17 = (unsigned char)*(lpSrc - 2 * lWidth );pixel18 = (unsigned char)*(lpSrc - 2 * lWidth + 1);pixel19 = (unsigned char)*(lpSrc - lWidth + 2);pixel20 = (unsigned char)*(lpS

9、rc + 2);pixel21 = (unsigned char)*(lpSrc + lWidth + 2);pixel22 = (unsigned char)*(lpSrc + 2 * lWidth + 1);pixel23 = (unsigned char)*(lpSrc + 2 * lWidth);pixel24 = (unsigned char)*(lpSrc + 2 * lWidth - 1);pixel25 = (unsigned char)*(lpSrc + lWidth - 2);pixel26 = (unsigned char)*(lpSrc - 2);pixel27 = (

10、unsigned char)*(lpSrc - lWidth - 2);pixel28 = (unsigned char)*(lpSrc - lWidth - 1);pixel29 = (unsigned char)*(lpSrc - lWidth);pixel30 = (unsigned char)*(lpSrc - lWidth + 1);pixel31 = (unsigned char)*(lpSrc + 1);pixel32 = (unsigned char)*(lpSrc + lWidth + 1);pixel33 = (unsigned char)*(lpSrc + lWidth)

11、;pixel34 = (unsigned char)*(lpSrc + lWidth - 1);pixel35 = (unsigned char)*(lpSrc - 1);pixel36 = (unsigned char)*lpSrc; n=0;for(x=0;x37;x+)if(abs(pixel36-pixelx)=30) /可根据实际情况确定阈值n+;r=0; if(nGetHDIB();/ 判断DIB是否为空if (hDIB != NULL)LPSTR lpDIB = (LPSTR) :GlobalLock(HGLOBAL) hDIB);/ 获取DIB宽度int cxDIB = (in

12、t) :DIBWidth(lpDIB);/ 获取DIB高度int cyDIB = (int) :DIBHeight(lpDIB);:GlobalUnlock(HGLOBAL) hDIB);CRect rcDIB;rcDIB.top = rcDIB.left = 0;rcDIB.right = cxDIB;rcDIB.bottom = cyDIB;CRect rcDest;/ 判断是否是打印if (pDC-IsPrinting()/ 是打印,计算输出图像的位置和大小,以便符合页面/ 获取打印页面的水平宽度(象素)int cxPage = pDC-GetDeviceCaps(HORZRES);/

13、获取打印页面的垂直高度(象素)int cyPage = pDC-GetDeviceCaps(VERTRES);/ 获取打印机每英寸象素数int cxInch = pDC-GetDeviceCaps(LOGPIXELSX);int cyInch = pDC-GetDeviceCaps(LOGPIXELSY);/ 计算打印图像大小(缩放,根据页面宽度调整图像大小)rcDest.top = rcDest.left = 0;rcDest.bottom = (int)(double)cyDIB * cxPage * cyInch)/ (double)cxDIB * cxInch);rcDest.righ

14、t = cxPage;/ 计算打印图像位置(垂直居中)int temp = cyPage - (rcDest.bottom - rcDest.top);rcDest.bottom += temp/2;rcDest.top += temp/2;else / 不必缩放图像rcDest = rcDIB;/ 输出DIB:PaintDIB(pDC-m_hDC, &rcDest, pDoc-GetHDIB(),&rcDIB, pDoc-GetDocPalette();/ 恢复正常光标 CPen *ppen=new CPen;ppen-CreatePen(PS_SOLID,1,RGB(255,0,0);pDC-SelectObject(ppen);for(int i=0;iMoveTo(corneri.x-3,corneri.y);pDC-LineTo(corneri.x+3,corneri.y);pDC-MoveTo(corneri.x,corner

温馨提示

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

评论

0/150

提交评论