这是一个简单的变换,对图像进行平滑处理,程序如下:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include "cv.h"
#include "highgui.h"
void Mysmooth(IplImage* image)
{
cvNamedWindow("image_in");
cvNamedWindow("image_out");
cvShowImage("image_in", image);
IplImage* out = cvCreateImage
(
cvGetSize(image), //图像的大小
IPL_DEPTH_8U,
3
);
cvSmooth(image, out, CV_GAUSSIAN, 3, 3);
cvShowImage("image_out", out);
cvReleaseImage(&out);
cvWaitKey(0);
cvDestroyWindow("image_out");
cvDestroyWindow("image_in");
}
int main()
{
IplImage* image = cvLoadImage("F:\\Opencv\\素材\\瓦力.jpg");
Mysmooth(image);
image = NULL;
return 0;
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
这个程序比较简单,大概思路就是建立一个储存图像属性的结构体传入平滑处理函数 Mysmooth中,在这个函数中,我们建立两个窗口(image_in和image_out),分别用来显示输入图像的显示和平滑处理后的输出图像显示。
再次提醒一个细节:创建了存储图像属性的结构体指针后,要记得释放内存。