图像算法之十:图像金字塔

来源:互联网 发布:为什么建设网络强国 编辑:程序博客网 时间:2024/05/16 15:21
一、基本原理   
   图像金字塔常用作多分辨率模型。视频图像的多分辨率模型是视频图像处理的重要方法。
图像金字塔包括高斯金字塔和拉普拉斯金字塔两种实现形式。
1、高斯金字塔:
  高斯金字塔的实现包括两步:高斯低通滤波和下采样。首先利用高斯核对图像进行卷积;然后进行下采样,得到不同尺度下的目标图像。

2、拉普拉斯金字塔:
拉普拉斯金字塔是建立在高斯金字塔的基础上的,就是高斯金字塔在不同层之间的差分。

二、算法实现
OpenCV实现:
#include <iostream>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>using namespace std;using namespace cv;int main(int argv, char* argc[]){       int levels = 2;       Mat img = imread("E:\\OpenCV\\Picture\\airplane.jpg",1);       namedWindow("original");       imshow("original", img);    Mat currentImg = img;       Mat lap = currentImg;       for (int l = 0; l<levels; l++) {         Mat down, up;      pyrDown(currentImg, down);         pyrUp(down, up, currentImg.size());         lap = currentImg - up;         currentImg = down;       }       namedWindow("Laplace Pyramid");       imshow("Laplace Pyramid", lap);       waitKey(0);       return 0;}

实验效果:



从原图和拉普拉斯金字塔图像可以看出,通过建立拉普拉斯金字塔,可以对特定尺度下的细节进行平滑和增强。
0 0