Image Pyramids – OpenCV 3.4 with python 3 Tutorial 23
Source code:
[python]
import cv2
import numpy as np
img = cv2.imread("hand.jpg")
# Gaussian Pyramid
layer = img.copy()
gaussian_pyramid = [layer]
for i in range(6):
layer = cv2.pyrDown(layer)
gaussian_pyramid.append(layer)
# Laplacian Pyramid
layer = gaussian_pyramid[5]
cv2.imshow("6", layer)
laplacian_pyramid = [layer]
for i in range(5, 0, -1):
size = (gaussian_pyramid[i – 1].shape[1], gaussian_pyramid[i – 1].shape[0])
gaussian_expanded = cv2.pyrUp(gaussian_pyramid[i], dstsize=size)
laplacian = cv2.subtract(gaussian_pyramid[i – 1], gaussian_expanded)
laplacian_pyramid.append(laplacian)
cv2.imshow(str(i), laplacian)
cv2.imshow("Original image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
[/python]
Files:

Hi there, I’m the founder of Pysource.
I’m a Computer Vision Consultant, developer and Course instructor.
I help Companies and Freelancers to easily and efficiently build Computer Vision Software.

Learn to build Computer Vision Software easily and efficiently.
This is a FREE Workshop where I'm going to break down the 4 steps that are necessary to build software to detect and track any object.
Sign UP for FREE