首页 > 代码库 > OpenCV学习笔记——多种Smooth平滑处理

OpenCV学习笔记——多种Smooth平滑处理

opencv库提供了好几种模糊平滑Smooth操作的类型作为cvSmooth的参数传入,从而达到不同的平滑效果,另外复习了一下如何复制一份图像和重新调整图像大小。

调整图像大小目前是按照一下步骤进行:

1、先cvcreate一个新的图像,cvcreate中的参数设为调整之后的大小(用Cvsize的构造函数封装代入)

2、然后再用cvresize把原图像输入到刚才构造的已设定好尺寸的图像中

代码:

#include<cv.h>#include<highgui.h>//多种smooth的样例int main(void){	IplImage *ori_src = http://www.mamicode.com/cvLoadImage("cc.jpg");	IplImage *src = http://www.mamicode.com/cvCreateImage(CvSize(ori_src->width>>1,ori_src->height>>1), ori_src->depth, ori_src->nChannels);"Orignal",CV_WINDOW_AUTOSIZE);	cvNamedWindow("Cvsmooth_blur");	cvNamedWindow("Cvsmooth_blur_no_scale");	cvNamedWindow("Cvsmooth_gaussian");	cvNamedWindow("Cvsmooth_medeian");	cvNamedWindow("Cvsmooth_bilateral");	cvSmooth(src, dst_blur, CV_BLUR, 3, 3, 0, 0);	cvSmooth(src, dst_blur_no_scale, CV_BLUR_NO_SCALE, 3, 3, 0, 0);	cvSmooth(src, dst_gaussian, CV_GAUSSIAN, 3, 3, 0, 0);	cvSmooth(src, dst_medeian, CV_MEDIAN, 3, 3, 0, 0);	cvSmooth(src, dst_bilateral, CV_BILATERAL, 3, 3, 0, 0);			cvShowImage("Orignal", src);	cvShowImage("Cvsmooth_blur", dst_blur);	cvShowImage("Cvsmooth_bur_no_scale", dst_blur_no_scale);	cvShowImage("Cvsmooth_gaussian", dst_gaussian);	cvShowImage("Cvsmooth_medeian", dst_medeian);	cvShowImage("Cvsmooth_bilateral", dst_bilateral);	cvWaitKey(0);	cvDestroyAllWindows();	cvReleaseImage(&ori_src);	cvReleaseImage(&src);	cvReleaseImage(&dst_blur);	cvReleaseImage(&dst_blur_no_scale);	cvReleaseImage(&dst_gaussian);	cvReleaseImage(&dst_medeian);	cvReleaseImage(&dst_bilateral);	return 0;}

OpenCV学习笔记——多种Smooth平滑处理