将图像缩放为原来的1/2:
#include "opencv/cv.h"
#include "opencv/highgui.h"
int main(int argc,char** argv)
{
IplImage* in = cvLoadImage(argv[1]);//载入图像
cvNamedWindow("IN",1);
cvNamedWindow("OUT",1);
cvShowImage( "IN", in );
// Best to make sure input image is divisible by two.
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 );
cvShowImage( "OUT", out );
cvWaitKey(0);
cvReleaseImage(&out);
cvReleaseImage(&in);
cvDestroyWindow("IN");
cvDestroyWindow("OUT");
return 0;
}
缩放前后的图像: