OpenCV image Processing (d) Image pyramid _ Image Pyramid

Source: Internet
Author: User

"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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.