cse cse - 8 months ago 56
Python Question

Reconstructed Image after Laplacian Pyramid Not the same as original image

I am converting an RGB image into YCbCr and then want to compute the laplacian pyramid for the same. After color conversion, I am experimenting with the code give on the Image Pyramid tutorial of OpenCV to find the Laplacian pyramid of an image and then reconstruct the original image. However, if I increase the number of levels in my code to a higher number, say 10, then the reconstructed image(after conversion back to RGB) does not look the same as the original image(image looks blurred - please see below link for the exact image). I am not sure why this is happening. Is it suppose to happen when the levels increase or is there anything wrong in the code?

frame = cv2.cvtColor(frame_RGB, cv2.COLOR_BGR2YCR_CB)
height = 10
Gauss = frame.copy()
gpA = [Gauss]
for i in xrange(height):
Gauss = cv2.pyrDown(Gauss)

lbImage = [gpA[height-1]]

for j in xrange(height-1,0,-1):
GE = cv2.pyrUp(gpA[j])
L = cv2.subtract(gpA[j-1],GE)

ls_ = lbImage[0]
for j in range(1,height,1):
ls_ = cv2.pyrUp(ls_)
ls_ = cv2.add(ls_,lbImage[j])

ls_ = cv2.cvtColor(ls_, cv2.COLOR_YCR_CB2BGR)
cv2.imshow("Pyramid reconstructed Image",ls_)

For reference, please see the reconstructed image and the original image.

Reconstructed Image

Original Image


pyrDown blurs an image and downsamples it, loosing some information. Saved pyramid levels (gpA[] here) contain smaller and smaller image matrices, but don't keep rejected information details (high-frequency ones).

So reconstructed image cannot show all original details

From tutorial: Note: When we reduce the size of an image, we are actually losing information of the image.