您的位置:首页 > 运维架构

OPenCV学习笔记(5)——图像缩放

2016-06-30 17:29 337 查看
将图像缩放为原来的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;
}


缩放前后的图像:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: