Image Pyramids are one of the most beautiful concept of image processing.Normally, we work with images with default resolution but many times we need to change the resolution (lower it) or resize the original image in that case image pyramids comes handy.
The pyrUp() function increases the size to double of its original size and pyrDown() function decreases the size to half. If we keep the original image as a base image and go on applying pyrDown function on it and keep the images in a vertical stack, it will look like a pyramid. The same is true for upscaling the original image by pyrUp function.

Once we scale down and if we rescale it to the original size, we lose some information and the resolution of the new image is much lower than the original one.
Below is an example of Image Pyramiding –
import cv2 import matplotlib.pyplot as plt img = cv2.imread("images/input.jpg") layer = img.copy() for i in range(4): plt.subplot(2, 2, i + 1) # using pyrDown() function layer = cv2.pyrDown(layer) plt.imshow(layer) cv2.imshow("str(i)", layer) cv2.waitKey(0) cv2.destroyAllWindows() |
Output:

Advantages of Image pyramids:
- Lowering of resolution
- Getting various sizes of image
- Image Blending
- Edge detection
Recommended Posts:
- Cartooning an Image using OpenCV - Python
- OpenCV Python Program to analyze an image using Histogram
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Reading an image in OpenCV using Python
- Python | Detect corner of an image using OpenCV
- Python | Image blurring using OpenCV
- Image Resizing using OpenCV | Python
- Find Circles and Ellipses in an Image using OpenCV | Python
- Image Translation using OpenCV | Python
- Image Registration using OpenCV | Python
- Python | Detect Polygons in an Image using OpenCV
- Image Steganography using OpenCV in Python
- Log transformation of an image using Python and OpenCV
- Image Processing in Java | Set 3 (Colored image to greyscale image conversion)
- Image Processing in Java | Set 4 (Colored image to Negative image conversion)
- Image Processing in Java | Set 6 (Colored image to Sepia image conversion)
- Image Processing using OpenCV in Java | Set 13 (Brightness Enhancement)
- Image Processing using OpenCV in Java | Set 14 ( Sharpness Enhancement )
- Image Inpainting using OpenCV
- OpenCV Python Program to blur an image
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

