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

[学习OpenCV攻略][007][缩小图片]

2015-10-28 21:37 465 查看
cvPryDown(输入图片,输出图片)

根据输出图片的大小,把输入图片进行压缩

cvPryUp(输入图片,输出图片)

根据输出图片的大小,把输入图片进行放大

#include "cv.h"
#include "highgui.h"

IplImage *doPyrUp(IplImage *in){
//assert(in->width%2 == 0 && in->height%2 == 0);

//IplImage *out = cvCreateImage(cvSize(in->width/2, in->height/2), in->depth, in->nChannels);
IplImage *out = cvCreateImage(cvSize(in->width*2, in->height*2), in->depth, in->nChannels);

//cvPyrDown(in, out);
cvPyrUp(in, out);

return out;
}

int main(int argc, char **argv){
IplImage *img = cvLoadImage(argv[1]);
//IplImage *img2 = cvCreateImage(cvSize(img->width/2, img->height/2), img->depth, img->nChannels);
IplImage *img2 = cvCreateImage(cvSize(img->width*2, img->height*2), img->depth, img->nChannels);

cvNamedWindow("hello1", CV_WINDOW_AUTOSIZE);
cvNamedWindow("hello2", CV_WINDOW_AUTOSIZE);
cvShowImage("hello1", img);

//img2 = doPyrDown(img);
img2 = doPyrUp(img);

cvShowImage("hello2", img2);

cvWaitKey(0);

cvReleaseImage(&img);
cvReleaseImage(&img2);
cvDestroyWindow("hello1");
cvDestroyWindow("hello2");

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