2019-07-13(day038_由高斯金字塔构造拉普拉斯金字塔:高斯金字塔中,从第i层开始,Laplacian金字塔中的第i层为:高斯金字塔第i - 1层**减去**高斯金字塔中第i层放大到...

c++

#include"all.h"
using namespace std;
using namespace cv;

void pyramid_up1(Mat &image, vector &pyramid_images, int level);
void laplaian_demo(vector &pyramid_images, Mat &image);
void MyClass::day038() {
    Mat img = read(PATH + "images\\test.jpg");
    vector vec;
    pyramid_up1(img, vec, 3);
    laplaian_demo(vec, img);
    waitKey(0);
}
void pyramid_up1(Mat &image, vector &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 laplaian_demo(vector &pyramid_images, Mat &image) {
    //laplaian金字塔每层都比gaussian金字塔大一倍
    Mat dst;
    for (int i = pyramid_images.size() - 1; i >= 0; i--) {
        if (i - 1 >= 0) {
            pyrUp(pyramid_images[i], dst, pyramid_images[i - 1].size());
            subtract(pyramid_images[i - 1], dst, dst);
            dst = dst + Scalar(127, 127, 127);
            imshow(format("laplaian_layer_%d", i), dst);
        }
        else {
            pyrUp(pyramid_images[i], dst, image.size());
            subtract(image, dst, dst);
            dst = dst + Scalar(127, 127, 127);
            imshow(format("laplaian_layer_%d", i), dst);
        }
    }

}

c++中的新知识点:
由高斯金字塔构造拉普拉斯金字塔:高斯金字塔中,从第i层开始,Laplacian金字塔中的第i层为:高斯金字塔第i - 1层减去高斯金字塔中第i层放大到第i - 1层大小的图片

你可能感兴趣的:(2019-07-13(day038_由高斯金字塔构造拉普拉斯金字塔:高斯金字塔中,从第i层开始,Laplacian金字塔中的第i层为:高斯金字塔第i - 1层**减去**高斯金字塔中第i层放大到...)