码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-09-09 17:00:47      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:

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

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

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

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

代码:

#include<cv.h>
#include<highgui.h>
//多种smooth的样例
int main(void)
{
	IplImage *ori_src = cvLoadImage("cc.jpg");
	IplImage *src = cvCreateImage(CvSize(ori_src->width>>1,ori_src->height>>1), ori_src->depth, ori_src->nChannels);

	cvResize(ori_src, src, CV_INTER_LINEAR);

	IplImage *dst_blur = cvCreateImage(cvGetSize(src), src->depth, src->nChannels);
	IplImage *dst_blur_no_scale= cvCreateImage(cvGetSize(src), src->depth, src->nChannels);
	IplImage *dst_gaussian = cvCreateImage(cvGetSize(src), src->depth, src->nChannels);
	IplImage *dst_medeian= cvCreateImage(cvGetSize(src), src->depth, src->nChannels);
	IplImage *dst_bilateral = cvCreateImage(cvGetSize(src), src->depth, src->nChannels);
	
	cvNamedWindow("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平滑处理

标签:

原文地址:http://www.cnblogs.com/Blackops/p/5857010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!