这部分知识还是很简单的,对图片的扩大与缩小,我们先看原理图吧:
代码部分:
// opencv0014.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
Mat src, dst;
src = imread("D:/images/8.jpg");
if (!src.data)
{
cout << "could not load image..." << endl;
return -1;
}
char INPUT_WIN[] = "input image";
char OUTPUT_WIN[] = "sample up";
namedWindow(INPUT_WIN, CV_WINDOW_AUTOSIZE);
namedWindow(OUTPUT_WIN, CV_WINDOW_AUTOSIZE);
imshow(INPUT_WIN, src);
//上采样
pyrUp(src, dst, Size(src.cols * 2, src.rows * 2));
imshow(OUTPUT_WIN, dst);
// 降采样
Mat s_down;
pyrDown(src, s_down, Size(src.cols / 2, src.rows / 2));
imshow("sample down", s_down);
waitKey(0);
return 0;
}