【学习opencv】IplImage平滑滤波 cvSmooth

对图像处理时用到的函数及头文件:

#include "stdafx.h"
#include "opencv2/opencv.hpp"
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <opencv2/nonfree/features2d.hpp>
using namespace std;
using namespace cv;

//对image进行平滑处理
void example2_4( IplImage* image )
{
	IplImage* out = cvCreateImage(
		cvGetSize(image),   //获得输入图片的大小,并进行创建,也可以使用cvSize()
		IPL_DEPTH_8U,
		3
		);
	//可以在此选择一种,作为自己的滤波方法
	cvSmooth( image, out, CV_GAUSSIAN, 5,5 );  //高斯平滑  调节参数平滑程度不同
// 	cvSmooth( image, out, CV_BLUR  );  //对每个象素param1×param2邻域 求和并做尺度变换
// 	cvSmooth( image, out, CV_BLUR_NO_SCALE ,3,3,3,3 );  //简单不带尺度变换的模糊 
// 	cvSmooth( image, out, CV_MEDIAN,5,5  );  //中值滤波
// 	cvSmooth( image, out, CV_BILATERAL ,10,10);  //双向滤波

	cvNamedWindow( "Example2_4-in", CV_WINDOW_AUTOSIZE );  //显示输入图片
	cvNamedWindow( "Example2_4-out", CV_WINDOW_AUTOSIZE ); //显示输出图片
	cvShowImage( "Example2_4-in", image );
	cvShowImage( "Example2_4-out", out );
	cvReleaseImage( &out );
	cvWaitKey( 0 ); 
	cvDestroyWindow("Example2_4-in" );
	cvDestroyWindow("Example2_4-out" );
}
int main( int argc, char** argv )
{
	const char* cNamesmooth="smooth.jpg";
	IplImage* img = cvLoadImage(cNamesmooth);
	example2_4( img );  //调用函数
	cvReleaseImage( &img );
}


你可能感兴趣的:(opencv,平滑,滤波)