1. 原理
考虑一个一维信号,该信号在t=1000时发生了阶跃,那么如何检测这个阶跃的位置呢?
图1分别用1阶高斯导数和2阶高斯导数对该信号进行卷积
(i);for(int j=0; j#if 1cornerLOG(srcImg, corner, &numCorner, height, width, minScale, maxScale, stepScale);
#elsecornerDOH(srcImg, corner, &numCorner, height, width, minScale, maxScale, stepScale);
#endifdelete[] srcImg;cv::Mat showImg;cvtColor(img, showImg, CV_GRAY2BGR);for(int i=0; i}void getLOGkernel(int halfWin, float sita, float** kernel)
{int winSize &#61; 2*halfWin&#43;1;float tmp1, tmp2, sumValue &#61; 0;float powsita &#61; sita*sita;for(int i&#61;-halfWin; i<&#61;halfWin; i&#43;&#43;){for(int j&#61;-halfWin; j<&#61;halfWin; j&#43;&#43;){tmp1 &#61; -1*(i*i&#43;j*j)/(2*powsita);tmp2 &#61; exp(tmp1)*(i*i&#43;j*j-2*powsita);//exp(tmp1)*(1&#43;tmp1)/(-1*powsita*powsita);sumValue &#43;&#61; tmp2;(*kernel)[(i&#43;halfWin)*winSize&#43;(j&#43;halfWin)] &#61; tmp2;}}for(int i&#61;0; i}void converlution(unsigned char* srcImg, int** dstImg, int height, int width, float* kernel, int kernelWin)
{for(int i&#61;0; i&#61;0 && m&#61;0 && n}bool isMax(int* compImg, int compValue, _point compPoint, int kerWin, int imgWidth, bool isSameK)
{for(int i&#61;compPoint.y-kerWin; i<&#61;compPoint.y&#43;kerWin; i&#43;&#43;){for(int j&#61;compPoint.x-kerWin; j<&#61;compPoint.x&#43;kerWin; j&#43;&#43;){if(isSameK && i&#61;&#61;compPoint.y && j&#61;&#61;compPoint.x)continue;if(abs(compValue) <&#61; abs(compImg[i*imgWidth&#43;j]))return false;}}return true;
}void cornerLOG(unsigned char* srcImg, _point* corner, int* count, int height, int width, float minScale, float maxScale, int stepScale)
{int numScale &#61; int((maxScale - minScale)/stepScale);int** scaledImg &#61; new int*[numScale]; for(int i&#61;0; i&#61;MAXPOINTS){for(int m&#61;0; m}void getDOHkernel(int halfWin, float sita, float** kernelxx, float** kernelyy, float** kernelxy)
{int winSize &#61; 2*halfWin&#43;1;float tmp1, tmpxx, tmpyy, tmpxy;float sumValuexx &#61; 0, sumValueyy &#61; 0, sumValuexy &#61; 0;float powsita &#61; sita*sita;for(int i&#61;-halfWin; i<&#61;halfWin; i&#43;&#43;){for(int j&#61;-halfWin; j<&#61;halfWin; j&#43;&#43;){tmp1 &#61; -1*(i*i&#43;j*j)/(2*powsita);tmpxx &#61; exp(tmp1)*(j*j-powsita);tmpyy &#61; exp(tmp1)*(i*i-powsita);tmpxy &#61; exp(tmp1)*i*j;sumValuexx &#43;&#61; tmpxx;sumValueyy &#43;&#61; tmpyy;sumValuexy &#43;&#61; tmpxy;(*kernelxx)[(i&#43;halfWin)*winSize&#43;(j&#43;halfWin)] &#61; tmpxx;(*kernelyy)[(i&#43;halfWin)*winSize&#43;(j&#43;halfWin)] &#61; tmpyy;(*kernelxy)[(i&#43;halfWin)*winSize&#43;(j&#43;halfWin)] &#61; tmpxy;}}for(int i&#61;0; i}void detValue(int** imgscale, int* imgxx, int* imgyy, int* imgxy, float scale, int height, int width)
{for(int i&#61;0; i}void cornerDOH(unsigned char* srcImg, _point* corner, int* count, int height, int width, float minScale, float maxScale, int stepScale)
{int numScale &#61; int((maxScale - minScale)/stepScale);int** scaledImg &#61; new int*[numScale]; for(int i&#61;0; i&#61;MAXPOINTS){for(int m&#61;0; m}
效果图&#xff08;左LOG&#xff0c;右DOH&#xff09;
![](https://img-blog.csdn.net/20151127150635377?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA&#61;&#61;/dissolve/70/gravity/Center)