学习OpenCV_例2.4: 载入一副图像并进行平滑处理

来源:互联网 发布:真正的人工智能股 编辑:程序博客网 时间:2024/06/06 08:37
/*例2.4: 载入一副图像并进行平滑处理*/#include "cv.h"#include "highgui.h"//定义函数void example2_4(IplImage* image){//Create some windows to show the inputcvNamedWindow("Example4-in");cvNamedWindow("Example4-out");//Create a window to show our input imagecvShowImage("Example4-in", image); //处理前的图像输出//Create an image to hold the smoothed outputIplImage* out = cvCreateImage(cvGetSize(image), //CvSize结构,通过cvGetSize(image)来获得,说明当前图像结构的大小(图像的宽高)IPL_DEPTH_8U, //各个通道每个像素点的数据类型3 //通道的总数); //当前图像是3个通道,每个通道8位,图像大小同image//Do the smoothing//每个像素周围3*3区域进行高斯平滑处理cvSmooth(image, out, CV_GAUSSIAN, 3, 3);//Show the smoothed image in the output windowcvShowImage("Example4-out", out); //平滑后的图像输出//By tidycvReleaseImage(&out);//Wait for the user to hit a key, the clean up the windowscvWaitKey(0);cvDestroyWindow("Example4-int");cvDestroyWindow("Example4-out");}int main(int argc, char** argv){IplImage *image = cvLoadImage("E:/lena.png");example2_4(image);return 0;}

0 0
原创粉丝点击