资 源 简 介
基于opencv对图像实行双线性插值缩放以及最临近插值缩放#include "highgui.h"
#include "cv.h"
IplImage *src=NULL;
IplImage *dst1,*dst2;
void main()
{
double scale1=0.1;
double scale2=10;
CvSize dst1_size;
CvSize dst2_size;
src=cvLoadImage("E:\学习\VC文件\c++ prictice\pro1\pro1.jpg");
//缩小系数
dst1_size.width=(int)(src->width*scale1);
dst1_size.height=(int)(src->height*scale1);
dst1=cvCreateImage(dst1_size,src->depth,src->nChannels);
cvResize(src,dst1,CV_INTER_NN);//像素插值(最邻近插值)缩小
//放大系数
dst2_size.width=(int)(dst1->width*scale2);
dst2_size.height=(int)(dst1->height*scale2);
dst2=cvCreateImage(dst2_size,src->depth,src->nChannels);
cvResize(dst1,dst2,CV_INTER_NN);//像素插值(最邻近插值)放大
cvNamedWindow("原图",CV_WINDOW_AUTOSIZE);
cvNamedWindow("缩小10倍后图",CV_WINDOW_AUTOSIZE);
cvNamedWindow("缩小10倍后再放大10倍还原图",CV_WINDOW_AUTOSIZE);
cvShowImage("原图",src);
cvShowImage("缩小