OpenCV学习之图像平滑

来源:互联网 发布:地瓜干 知乎 编辑:程序博客网 时间:2024/05/21 19:24
#include "cv.h"#include "highgui.h"//平滑变换void example2_4(IplImage* image){    cvNamedWindow("Example2_4-in", CV_WINDOW_AUTOSIZE);    cvNamedWindow("Example2_4-out", CV_WINDOW_AUTOSIZE);    cvShowImage("Example2_4-in", image);    IplImage* out = cvCreateImage(        //创建图像结构体指针,用来储存平滑后的图像        cvGetSize(image), //尺寸、每个像素的位数、通道数        IPL_DEPTH_8U,        3    );    cvSmooth(image, out, CV_GAUSSIAN, 9, 9);    //参数1-输入图像,参数2-输出,参数3-平滑的类型,参数4、5-平滑块的尺寸    // Show the smoothed image in the output window    cvShowImage("Example2_4-out", out);    cvReleaseImage(&out);    // Wait for the user to hit a key, then clean up the windows    cvWaitKey(0);    cvDestroyWindow("Example2_4-in");    cvDestroyWindow("Example2_4-out");}int main(int argc, char** argv){    IplImage* img = cvLoadImage("Lena.tif");    cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);    cvShowImage("Example1", img);    example2_4(img);    cvWaitKey(0);    cvReleaseImage(&img);    cvDestroyWindow("Example1");}
原创粉丝点击