OpenCV笔记9:图像的缩放

运行结果



源代码:
#include "StdAfx.h"
#include "cv.h"
#include "highgui.h"


IplImage* doPyrDown(
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/2, in->height/2),
//cvSize(cvGetSize(in)),
IPL_DEPTH_8U,
1
);


cvCanny(in,out,lowThresh,highThresh,aperture);
return(out);
};


int main( int argc, char** argv )
{
IplImage* in=cvLoadImage("beauty.jpg");
cvNamedWindow( "Image1", 1 );//创建窗口
cvNamedWindow( "Image2", 1 );//创建窗口
cvNamedWindow( "Image3", 1 );//创建窗口
    IplImage* img1=doPyrDown(in,IPL_GAUSSIAN_5x5); 
IplImage* img2=doPyrDown(img1,IPL_GAUSSIAN_5x5); //声明IplImage指针
IplImage* img3=doCanny(img2,10,100,3);


cvShowImage( "Image1",img1 );//显示图像
cvShowImage( "Image2",img2 );//显示图像
cvShowImage( "Image3",img3 );//显示图像


        cvWaitKey(0); //等待按键


    cvReleaseImage( &img1 );
    cvReleaseImage( &img2 );
    cvReleaseImage( &img3 );
    


    return -1;
}

你可能感兴趣的:(OpenCV)