-
Notifications
You must be signed in to change notification settings - Fork 22
/
gaussianPyramid.py
36 lines (28 loc) · 882 Bytes
/
gaussianPyramid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
def gaussianPyramid():
'''
A level in laplacian Pyramid is formed by the difference
between that level in Gaussian Pyramid and expanded version
of its upper lavel in Gaussian Pyramid.
'''
img = cv.imread('./img/balls.jpg')
layer = img.copy()
gp = [layer]
for i in range(1):
layer = cv.pyrDown(layer)
gp.append(layer)
# cv.imshow(str(i), layer)
layer = gp[len(gp)-1]
lp = [layer]
cv.imshow('Last Gaussian Image', layer)
for i in range(len(gp)-1, 0, -1):
gaussian_extended = cv.pyrUp(gp[i])
laplacian = cv.subtract(gp[i-1], gaussian_extended)
cv.imshow(str(i), laplacian)
cv.imshow("Original Image", img)
cv.waitKey()
cv.destroyAllWindows()
if __name__ == '__main__':
gaussianPyramid()