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) gpA.append(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) lbImage.append(L) 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_) cv2.waitKey(0)
For reference, please see the reconstructed image and the original image.