OpenCv(1):简单的输入输出 分类: OpenCv 2014-08-28 16:27 100人阅读 评论(0) 收藏

今天开始学习OpenCv, 通过图像放缩和canny算子熟悉了一下怎么用OpenCv读入和显示图片,cvSize(cvGetSize(n))这一句总是报错,是说只有一个参数,书上的代码有点问题。


#include "cv.h"

#include "highgui.h"


void example2_4(IplImage* image){
cvNamedWindow("Example4-in");
        cvNamedWindow("Example4-out");
cvShowImage("Example4-in", image);


IplImage* out= cvCreateImage(
cvGetSize(image),
       IPL_DEPTH_8U,3
);
cvSmooth(image, out, CV_GAUSSIAN,3,3);
cvShowImage("Example4-out", out);


cvReleaseImage(&out);
cvWaitKey(0);
cvDestroyWindow("Example4_in");
cvDestroyWindow("Example4-out");
}


IplImage* cvPyrDown(IplImage* in,int filter=IPL_GAUSSIAN_5x5){

assert( in->width%2 == 0 && in->height%2 ==0);
IplImage* out=cvCreateImage(
cvSize(in->width/2,in->height/2),
in->depth,
in->nChannels
);
cvPyrDown(in,out);
return(out);

};


IplImage* doCanny(IplImage* in,double lowThresh,double highThresh,double aperture){
if(in->nChannels !=1)
return(0);
 
IplImage* out= cvCreateImage(
cvSize(in->width,in->height) ,
IPL_DEPTH_8U,
1
);
cvCanny(in,out,lowThresh,highThresh,aperture);
return(out);
};

版权声明:本文为博主原创文章,未经博主允许不得转载。

原文地址:https://www.cnblogs.com/learnordie/p/4657019.html