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<Mat> &pyramid_images, int level);
void laplaian_demo(vector<Mat> &pyramid_images, Mat &image);
void MyClass::day038() {
    Mat img = read(PATH + "images\\test.jpg");
    vector<Mat> vec;
    pyramid_up1(img, vec, 3);
    laplaian_demo(vec, img);
    waitKey(0);
}
void pyramid_up1(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 laplaian_demo(vector<Mat> &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层大小的图片

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容