高斯平滑:
//对图像进行平滑处理
cvNamedWindow( "smooth-out" );
//当前图像结构的大小,各通道每个像素点的数据类型,通道的总数
IplImage* out = cvCreateImage(
cvGetSize(img),
IPL_DEPTH_8U,
3
);
cvSmooth( img, out, CV_GAUSSIAN, 3, 3 );
cvShowImage( "smooth-out", out );
边缘检测和缩放,canny
IplImage* doPyrDown(
IplImage* in,
bool isPyr,
double lowThresh,
double highThresh,
double aperture)
{
// Best to make sure input image is divisible by two.
//
// assert( in->width%2 == 0 && in->height%2 == 0 );
IplImage* out = NULL;
if(isPyr){
out = cvCreateImage(
cvSize( in->width/2, in->height/2 ),
in->depth,
in->nChannels
);
//cvPyrDown() 创建一幅宽度和高度为输入图像一半尺寸的图像
cvPyrDown( in, out );
}else{
if(in->nChannels != 1)
return(0);
/*
* Canny边缘检测将输出写入一个单通道(灰度级)图像*/
IplImage* out = cvCreateImage(
cvGetSize(in),
IPL_DEPTH_8U,
1
);
cvCanny( in, out, lowThresh, highThresh, aperture );
}
return( out );
};