pyramid, or pyramid representation, is a type of multi-scale signal representation in which a signal or image is subject to repeated smoothing and subsampling.
Types of pyramid:
1. Gaussian pyramid
2. Laplacian pyramid
-A lavel in laplacian pyramid is formed by the difference between that level in Gaussian pyramid and expanded version of its upper level in Gaussian pyramid.
Uses of laplacian/Gaussian pyramid: help us to bland the images and reconstruction of the images.
import cv2
import numpy as np
img = cv2.imread("lena.jpg")
#lower resolution
#lr1 = cv2.pyrDown(img)
#lr2 = cv2.pyrDown(lr1)
#higher resolution
#hr2 = cv2.pyrUp(lr2)
#cv2.imshow("pyrDown 1 image", lr1)
#cv2.imshow("pyrDown 2 image", lr2)
#cv2.imshow("pyrUp 1 image", hr2)
#in gaussian two methods available
#-pyrDown and pyrUp
#but in laplacian pyramid no methods available
#A level in laplacian pyramid is formed by the difference between that lavel
#in gaussian pyramid and expanded version of its upper level in gaussian pyramid
layer = img.copy()
gp=[layer]
for i in range(6):
layer = cv2.pyrDown(layer)
gp.append(layer)
# cv2.imshow(str(i), layer)
layer = gp[5]
cv2.imshow('upper level gaussian pyramid', layer)
lp = [layer]
for i in range(5, 0, -1):
# print(i)
gaussian_extended = cv2.pyrUp(gp[i])
laplacian = cv2.subtract(gp[i-1], gaussian_extended)
cv2.imshow(str(i), laplacian)
cv2.imshow("Original image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
import numpy as np
img = cv2.imread("lena.jpg")
#lower resolution
#lr1 = cv2.pyrDown(img)
#lr2 = cv2.pyrDown(lr1)
#higher resolution
#hr2 = cv2.pyrUp(lr2)
#cv2.imshow("pyrDown 1 image", lr1)
#cv2.imshow("pyrDown 2 image", lr2)
#cv2.imshow("pyrUp 1 image", hr2)
#in gaussian two methods available
#-pyrDown and pyrUp
#but in laplacian pyramid no methods available
#A level in laplacian pyramid is formed by the difference between that lavel
#in gaussian pyramid and expanded version of its upper level in gaussian pyramid
layer = img.copy()
gp=[layer]
for i in range(6):
layer = cv2.pyrDown(layer)
gp.append(layer)
# cv2.imshow(str(i), layer)
layer = gp[5]
cv2.imshow('upper level gaussian pyramid', layer)
lp = [layer]
for i in range(5, 0, -1):
# print(i)
gaussian_extended = cv2.pyrUp(gp[i])
laplacian = cv2.subtract(gp[i-1], gaussian_extended)
cv2.imshow(str(i), laplacian)
cv2.imshow("Original image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
No comments:
Post a Comment