c++
#include"all.h"
using namespace std;
using namespace cv;
void pyramid_up(Mat &image, vector<Mat> &pyramid_images, int level);
void pyramid_down(vector<Mat> pyramid_images);
void MyClass::day037() {
Mat img = read(PATH + "images\\test.jpg");
imshow("input", img);
vector<Mat> vec;
pyramid_up(img, vec, 3);
pyramid_down(vec);
waitKey(0);
}
void pyramid_up(Mat &image, vector<Mat> &pyramid_images, int level) {
Mat temp = image.clone();
Mat dst;
for (int i = 0; i < level; i++) {
pyrDown(temp, dst);
temp = dst.clone();
pyramid_images.push_back(temp);
}
}
void pyramid_down(vector<Mat> pyramid_images) {
Mat dst;
for (int i = pyramid_images.size() - 1; i >= 0; i--) {
pyrUp(pyramid_images[i], dst);
imshow(format("pyramid_down_%d", i), dst);
}
}
c++中的新知识点
pyrUp:从小到大回复金字塔中的图像
pyrDown:从大到小构造金字塔,原图不在金字塔内