现在的位置: 首页 > 综合 > 正文

opencv 学习第二天 学习opencv(中文版)对一幅图片进行高斯平滑并缩小一半

2013年08月19日 ⁄ 综合 ⁄ 共 787字 ⁄ 字号 评论关闭
#include <opencv2/highgui/highgui.hpp>
#include <cv.h>
using namespace std;
using namespace cv;
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);
	return out;
}
void main()
{
	IplImage *image = cvLoadImage("D:\\1.png");
	cvNamedWindow("example4-in");
	cvNamedWindow("example4-out");
	cvShowImage("example4-in",image);
	cvShowImage("example4-pyrdown",dopyrDown(image));
	//imshow("example4-in",image);
	//Mat out = cvCreateImage(cvGetSize(&image),IPL_DEPTH_8U,3);
	IplImage *out = cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3);
	cvSmooth(image,out,CV_GAUSSIAN,3,3,0,0);//高斯平滑
	cvShowImage("example4-out",out);
	
	cvReleaseImage(&out);
	waitKey(0);
	cvDestroyAllWindows();
	system("pause");
}

抱歉!评论已关闭.