1、harry 角点检测 c+源代码.txt 老公如果你只能在活一天,我愿用我的生命来延续你的生命,你要快乐的生活在提出分手的时候请不要说还爱我。harry 角点检测 c+源代码作者:dylan 日期:2009-01-23字体大小: 小 中 大 void Harry(BYTE*BBuf,BYTE*GBuf,BYTE*RBuf)/gausswidth:二维高斯窗口宽度/sigma:高斯函数的方差/size:非极大值抑制的邻域宽度/thresh:最终确定角点所需的阈值int i,j,m,n,size,thresh,gausswidth;double sigma;/输入四个参数/CInput2 inpu
2、t;/input.m_gausswidth =5;/input.m_sigma =0.8;/input.m_size =5;/input.m_thresh =5000;/input.DoModal ();gausswidth=5;/input.m_gausswidth ;sigma=0.8;/input.m_sigma ;size=5;/input.m_size ;thresh=5000;/input.m_thresh ;unsigned char *lpSrc;/一个指向源、目的像素的移动指针/LPSTR lpDIB = (LPSTR) :GlobalLock(HGLOBAL)m_hDIB)
3、;int cxDIB = 320;/(int) :DIBWidth(lpDIB); / 图像宽度int cyDIB = 240;/(int) :DIBHeight(lpDIB); / 图像高度/LPSTR lpDIBBits=:FindDIBBits (lpDIB);long lLineBytes = 320;/WIDTHBYTES(cxDIB * 8); / 计算灰度图像每行的字节数/创建 I、Ix、Ix2、Iy、Iy2、Ixy、cim、mx、corner 数组double *I=new doublecxDIB*cyDIB;double *Ix=new doublecxDIB*cyDIB;d
4、ouble *Ix2=new doublecxDIB*cyDIB;double *Iy=new doublecxDIB*cyDIB;double *Iy2=new doublecxDIB*cyDIB;double *Ixy=new doublecxDIB*cyDIB;double *cim=new doublecxDIB*cyDIB;double *mx=new doublecxDIB*cyDIB;bool*corner=new boolcxDIB*cyDIB;memset(corner, 0, cxDIB*cyDIB*sizeof(bool);/定义宏以方便访问元素#define I(ROW
5、,COL) IcxDIB*(ROW)+(COL)#define Ix(ROW,COL) IxcxDIB*(ROW)+(COL)#define Ix2(ROW,COL) Ix2cxDIB*(ROW)+(COL)#define Iy(ROW,COL) IycxDIB*(ROW)+(COL)#define Iy2(ROW,COL) Iy2cxDIB*(ROW)+(COL)#define Ixy(ROW,COL) IxycxDIB*(ROW)+(COL)#define cim(ROW,COL) cimcxDIB*(ROW)+(COL)#define mx(ROW,COL) mxcxDIB*(ROW)+
6、(COL)#define corner(ROW,COL) cornercxDIB*(ROW)+(COL)/将图像灰度值复制到 I 中,这步很重要!想想为什么?for(i = 0; i int(size/2) if(max0)mx(i,j)=max;elsemx(i,j)=0;fp=fopen(“mx.txt“,“w+“);for(i = 0; i thresh) /然后大于这个阈值corner(i,j)=1; /满足上两个条件,才是角点!fp=fopen(“corner.txt“,“w+“);for(i = 0; i int(tpH/2) mtpH;m+)for(n=0;ntpW;n+)a+=im(i+m-int(tpH/2),j+n-int(tpW/2)*tp(m,n);out(i,j)=a;return out;