在图像处理中常用的特征:
边缘:使用最多的:sobel canny susan
sobel:这个还可以来求梯度方向
void sobel_te(IplImage *img,IplImage * sobel8u)
{
IplImage* sobel=cvCreateImage( cvGetSize(img), IPL_DEPTH_16S, 1 );
IplImage* sobel_y=cvCreateImage( cvGetSize(img), IPL_DEPTH_16S, 1 );
IplImage* sobel_x=cvCreateImage( cvGetSize(img), IPL_DEPTH_16S, 1 );
cvSobel(img,sobel_y,1,0,3); //提取Y方向
cvSobel(img,sobel_x,1,0,3); //提取X方向
cvOr(sobel_x,sobel_y,sobel,NULL);
cvConvertScaleAbs(sobel,sobel8u,1,0);//把sobel计算后的值由16位转为8位供正常显示
sobel8u->origin = img->origin;
}
susan:这是在网上找到的,注意边缘检测后再显示中图像会和正常的不太一样,调用该函数的时候实参nimg,最好cvcloneimg后再做。
void :susan_bianyuan(const IplImage *Img,IplImage * nimg)
{
int height ,width ,step ,channels ;
int i,j,k,same ,max,min,thresh,sum;
uchar*data0,*data1 ;
height = Img->height;
width = Img->width;
step = Img->widthStep/sizeof(uchar);
channels = Img->nChannels;
data0 = (uchar*)Img->imageData;
data1 = (uchar*)nimg->imageData;
int OffSetX[37] = { -1, 0, 1,
-2,-1, 0, 1, 2,
-3,-2,-1, 0, 1, 2, 3,
-3,-2,-1, 0, 1, 2, 3,
-3,-2,-1, 0, 1, 2, 3,
-2,-1, 0, 1, 2,
-1, 0, 1 };
int OffSetY[37] = { -3,-3,-3,
-2,-2,-2,-2,-2,
-1,-1,-1,-1,-1,-1,-1,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2,
3, 3, 3 };
max = min = data0[0];
for(i=3;i<height-3;i++)
for(j=3;j<width-3;j++)
{