"Image Pyramid"
Image Pyramid is the word that we often see in many places. It is an image multi-scale expression, the most important is for image segmentation. at the same time, Image pyramid is also widely used in various visual applications.
Image Pyramid is an image set, all the images in the set originate from the same original image, but are obtained by successive drop sampling of the original image, until a certain termination condition is reached to stop the sampling. We can illustrate the concept of image pyramid by the image below. At the bottom of the pyramid is the high-resolution representation of the image to be processed, while the top is the low-resolution approximation. In the pyramid, the higher the hierarchy, the smaller the image, the lower the resolution.
In the literature, we often encounter two very typical image pyramid- Gauss Pyramid and Laplace Pyramid.
Gauss Pyramid : Sampling images to descent
Laplace pyramid : Images are reconstructed from the lower image.
The specific process that we can describe below:
Gauss Pyramid : Pyramid from the I layer to generate the i+1 layer, we need to first use gauss check GI for convolution , and then Delete all even rows and even sequence . In this way, the newly obtained image area becomes One-fourth of the source image. The whole pyramid can be generated by looping through the above process.
The Laplace pyramid : The image first expands to twice times each dimension, the new row is filled with 0 , and then the specified filter is convolution (actually a filter that expands to twice times each dimension) to estimate " The approximate value of the pixel is missing. After the image compared with the original image will be found more blurred, lost some information. In order to restore the original image, we need to obtain these missing information, which constitutes the Laplace pyramid.
Two functions are given in the OPENCV, respectively, providing a function cvpyrdown () and Cvpyrup () that generate the next level image from the top image of the pyramid and expand the known image to twice times each dimension ():
void Cvpyrdown (
iplimage* src,
iplimage* DST,
iplfilter filter=cv_gaussian_5x5
)
void Cvpyrup (
iplimage* src,
iplimage* DST,
iplfilter filter=cv_gaussian_5x5
)
The following is an example of an application of this function:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
int main ()
{
iplimage* src = cvloadimage ("1.jpg", cv_load_image_unchanged);
Cvshowimage ("source", SRC);
iplimage* dst1 = Cvcreateimage (Cvsize (SRC->WIDTH/2, SRC->HEIGHT/2), src->depth, src->nchannels);
Cvpyrdown (SRC, dst1, cv_gaussian_5x5);
Cvshowimage ("Dst1", dst1);
iplimage* dst2 = Cvcreateimage (Cvsize (src->width*2, src->height*2), src->depth, src->nchannels);
Cvpyrup (SRC, dst2, cv_gaussian_5x5);
Cvshowimage ("Dst2", dst2);
Cvwaitkey (0);
Cvreleaseimage (&SRC);
Cvreleaseimage (&dst1);
Cvreleaseimage (&DST2);
Cvdestroyallwindows ();
return 0;
}
The results of the program running are as follows: