核心函数:cvSmooth

程序:

代码:

#include "cv.h"#include "cxcore.h"#include "highgui.h"#include 
int smooth(int argc,char** argv){IplImage* src=cvLoadImage("e:\\picture\\123.bmp",0);cvNamedWindow("src");cvShowImage("src",src);IplImage* dst1=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);IplImage* dst2=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);IplImage* dst3=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);IplImage* dst4=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);IplImage* dst5=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);cvSmooth(src,dst1,CV_BLUR,3,3);  //简单模糊cvSmooth(src,dst2,CV_BLUR_NO_SCALE,3,3);  //简单无缩放变换的模糊cvSmooth(src,dst3,CV_MEDIAN,3,3); //中值模糊,可以避免孤立点的影响cvSmooth(src,dst4,CV_GAUSSIAN,3,3);  //高斯模糊,可以在保留信号的条件下减少噪声,但是接近边缘无效cvSmooth(src,dst5,CV_BILATERAL,3,3);  //双边滤波,不会将边缘平滑掉cvNamedWindow("CV_BLUR");cvNamedWindow("CV_BLUR_NO_SCALE");cvNamedWindow("CV_MEDIAN");cvNamedWindow("CV_GAUSSIAN");cvNamedWindow("CV_BILATERAL");cvShowImage("CV_BLUR",dst1);cvShowImage("CV_BLUR_NO_SCALE",dst2);cvShowImage("CV_MEDIAN",dst3);cvShowImage("CV_GAUSSIAN",dst4);cvShowImage("CV_BILATERAL",dst5);cvWaitKey(0);return 0;}