opencv对图片的处理

来源:互联网 发布:c语言实现cp命令 编辑:程序博客网 时间:2024/04/27 17:36
#include "stdafx.h"#include <cv.h>#include <highgui.h>IplImage* deCanny(IplImage* in, double lowThresh, double highThresh, double aperture){if(in->nChannels != 3){return(0);}IplImage* out = cvCreateImage(//为out边缘图像申请空间cvSize(cvGetSize(in).width,cvGetSize(in).height),IPL_DEPTH_8U,1);cvNamedWindow("out");//创建窗口cvCanny(in, out, lowThresh, highThresh, aperture);//in边缘检测return(out);}IplImage* dopyDown(IplImage* in,int filter = IPL_GAUSSIAN_5x5){assert(in->width%2 == 0 && in->height%2 == 0);IplImage* out = cvCreateImage(//为out申请空间,为1/4大小cvSize(in->width/2,in->height/2),in->depth,in->nChannels);cvPyrDown(in,out);//将in按比例缩小复制给outreturn(out);}void example2_4(IplImage* image){cvNamedWindow("in");cvShowImage("in",image);/*IplImage* out = cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3);*/IplImage* out = deCanny(image,50,150,3);//IplImage* out = dopyDown(image,IPL_GAUSSIAN_5x5);//out = dopyDown(out,IPL_GAUSSIAN_5x5);//cvSmooth(image,out,CV_GAUSSIAN,3,3);//平滑处理,图像会变模糊cvShowImage("out",out);cvReleaseImage(&out);cvWaitKey(0);cvDestroyWindow("in");cvDestroyWindow("out");}int _tmain(int argc, _TCHAR* argv[]){IplImage* img = cvLoadImage("拍照时间-02-06-09.bmp");example2_4(img);return 0;}

原创粉丝点击