0
点赞
收藏
分享

微信扫一扫

opencv图像金字塔-上采样和降采样

main.cpp

#include <istream>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;


int main(int argc, char **argv) {
    Mat src, up_dst, down_dst;
    //    加载图片
    src = imread("../../picture/bg1.webp", 1);
    if (!src.data) {
        printf("No image data \n");
        return -1;
    }
    char src_title[] = "src";
    namedWindow(src_title, WINDOW_AUTOSIZE);
    imshow(src_title, src);

    // 上采样
    char up_title[] = "up";
    pyrUp(src, up_dst, Size(src.cols * 2, src.rows * 2));
    namedWindow(up_title, WINDOW_AUTOSIZE);
    imshow(up_title, up_dst);

    // 降采样
    char down_title[] = "down";
    pyrDown(src, down_dst, Size(src.cols / 2, src.rows / 2));
    namedWindow(down_title, WINDOW_AUTOSIZE);
    imshow(down_title, down_dst);

    // 高斯不同DOG
    Mat gray_src, g1, g2, dst;
    cvtColor(src, gray_src, COLOR_BGR2GRAY);
    GaussianBlur(gray_src, g1, Size(5, 5), 0, 0);
    GaussianBlur(g1, g2, Size(5, 5), 0, 0);
    subtract(g1, g2, dst, Mat());

    // 归一化显示
    normalize(dst, dst, 255, 0, NORM_MINMAX);
    char dog_title[] = "DOG";
    namedWindow(dog_title, WINDOW_AUTOSIZE);
    imshow(dog_title, dst);

    //    等待按键
    waitKey(0);
    return 0;
}

opencv图像金字塔-上采样和降采样_加载图片

 


举报

相关推荐

0 条评论