#include <highgui.h>
#include <cv.h>
void example2_4(IplImage * image)
{
cvNamedWindow("example-in");
cvNamedWindow("example-out");
cvShowImage("example-in",image);
IplImage * out = cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3);//size是个结构体(宽,长);无符号8位整型 3通道:即:RGB 另外有1通道和4通道
1通道是灰度图,4通道是RGB外加透明度。
cvSmooth(image,out,CV_GAUSSIAN,3,3);
cvShowImage("example-out",out);
cvReleaseImage(&out);
cvWaitKey(0);
cvDestroyWindow("example-out");
cvDestroyWindow("example-in");
}
int main()
{
IplImage * image=cvLoadImage("I:\\资料\\opencv相关资料\\OpenCV教程\\图像与视频\\airplane.png");
example2_4(image);
return 0;
}
1.cvCreateImage用法:
IplImage * out = cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3);
size – Image width and height,结构体
depth – Bit depth of image elements. See IplImage for valid depths.
channels – Number of channels per pixel. See IplImage for details. This function only creates images with interleaved channels.
2.cvSmooth用法:
void cvSmooth(const CvArr* src, CvArr* dst, int smoothtype=CV_GAUSSIAN, int param1=3, int param2=0, double param3=0, double param4=0);
int smoothtype=CV_GAUSSIAN
int param1=3, int param2=0, double param3=0 ,double param4=0);
src:输入图像.
dst:输出图像.
smoothtype:平滑方法
CV_GAUSSIAN (gaussian blur) - 对图像进行核大小为 param1×param2 的高斯卷积.