OpenCV学习笔记——多种Smooth平滑处理
Posted Blackops
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenCV学习笔记——多种Smooth平滑处理相关的知识,希望对你有一定的参考价值。
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平滑处理的主要内容,如果未能解决你的问题,请参考以下文章