I'm trying to get a layer of the Laplacian pyramid using the opencv functions: pyrUp and pyrDown.
I'm trying to create a Laplacian pyramid using OpenCV. According to the openCV documentation, there is a way to do this using the following expression:
Li = Gi - pyrDown(Gi+1)
where Gi is the i-th layer of the Gaussian pyramid.
This is is what I've been able to do till now
def get_laplacian_pyramid_layer(img, n):
gi = img
for i in range(n):
gi_prev = gi
gi = cv2.pyrDown(gi_prev)
pyrup = cv2.pyrUp(gi)
return cv2.addWeighted(gi_prev, 1.5, pyrup, -0.5, 0)
The problem is that I get different sizes of the images that are used in the subtractions. And I have no clue why this is happening