边缘检测算法及图像金字塔

#include"highGUI.h"
#include"cv.h"
IplImage *doPyrDown(IplImage *in, int filter = IPL_GAUSSIAN_5x5)
{
	assert(in->width % 2 == 0 && in->height % 2 == 0);
	IplImage *out = cvCreateImage(cvSize(in->width / 2, in->height / 2), in->depth, in->nChannels);	//新图像是从旧图像中读取信息
	cvPyrDown(in, out);//用Gaussian金字塔分解对输入图像向下采样。
	return (out);
}
int main(int argc, char *argv[])
{
	IplImage *in = cvLoadImage("D:\\3.jpg");//第二个参数设为0的作用是将图片转化为灰色
	cvNamedWindow("show", CV_WINDOW_AUTOSIZE);
	cvShowImage("show", in);

	cvNamedWindow("win2", CV_WINDOW_AUTOSIZE);
	IplImage *out = cvCreateImage(cvGetSize(in), IPL_DEPTH_8U, 1);//写入单通道图像
	cvCanny(in, out, 50, 150, 3);//边缘检测算法
	cvShowImage("win2", out);

	//IplImage *out = doPyrDown(in);

	cvWaitKey(0);
	cvReleaseImage(&in);
	cvReleaseImage(&out);
	cvDestroyWindow("show");
	cvDestroyWindow("win2");
}

你可能感兴趣的:(边缘检测算法及图像金字塔)