Python Image Processing (16): Image pyramid, python Image Processing
Happy shrimp
Http://blog.csdn.net/lights_joy/
Reprinted, but keep the author information
The image pyramid is a type of multi-scale expression in the image. It was originally used for machine vision and image compression. The pyramid of an image is a collection of images arranged in the pyramid shape with a gradually reduced resolution derived from the same original image. It is obtained by performing step-by-step downward sampling and stops sampling until a certain termination condition is reached. The bottom of the pyramid is a high-resolution representation of the image to be processed, while the top is a low-resolution approximation. The higher the level, the smaller the image, and the lower the resolution.
Generally, two types of image pyramid are often used in literature and practical use. They are:
Gaussianpyramid: The main image pyramid used for downward sampling.
Laplacianpyramid: used to reconstruct An unsampled image from the lower layer of the pyramid. in digital image processing, it is also a prediction residual, which can be used to restore the image to the maximum extent, used with the Gaussian pyramid.
A brief difference between the two: the Gaussian pyramid is used to sample the image downward, while the Laplace pyramid is used to sample and reconstruct an image from the bottom layer of the pyramid.
The upward and downward sampling in the image pyramid are implemented by using the OpenCV functions pyrUp and pyrDown. The downward sampling and upward sampling are for the image size (opposite to the pyramid direction). The upward sampling means that the image size is doubled, and the downward sampling means that the image size is halved.
Note that PryUp and PryDown are not reciprocal, that is, PryUp is not the inverse operation of downsample. In this case, the image first doubles the size of each dimension, and the new rows (even rows) are filled with 0. Then, convolution is performed on the specified filter (in fact, a filter that doubles in every dimension) to estimate the approximate value of the "lost" pixel.
Try Python:
# Image pyramid src = cv2.imread ('f: \ tmp \ cotton.jpg ') cv2.imshow ('src', src) # bottom sample dst = cv2.pyrDown (src) cv2.imshow ('dst ', dst) # sample src1 = cv2.pyrUp (dst) cv2.imshow ('src1', src1) cv2.waitKey ()
Our original images:
Image after downsample:
Restored image:
The image is obviously blurred.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.