Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- apple = cv2.imread('C:\\Users\\quntu\\Desktop\\coding\\apple.jpg')
- orange = cv2.imread('C:\\Users\\quntu\\Desktop\\coding\\orange.jpg')
- apple_copy = apple.copy()
- gaussian_pyramid_apple = [apple_copy]
- for i in range(6):
- apple_copy = cv2.pyrDown(apple_copy)
- gaussian_pyramid_apple.append(apple_copy)
- orange_copy = orange.copy()
- gaussian_pyramid_orange = [orange_copy]
- for i in range(6):
- orange_copy = cv2.pyrDown(orange_copy)
- gaussian_pyramid_orange.append(orange_copy)
- apple_copy = gaussian_pyramid_apple[5]
- lp_apple = [apple_copy]
- for i in range(5, 0, -1):
- gaussian_expanded = cv2.pyrUp(gaussian_pyramid_apple[i])
- laplacian = cv2.subtract(gaussian_pyramid_apple[i-1], gaussian_expanded)
- lp_apple.append(laplacian)
- orange_copy = gaussian_pyramid_orange[5]
- lp_orange = [orange_copy]
- for i in range(5, 0, -1):
- gaussian_expanded = cv2.pyrUp(gaussian_pyramid_orange[i])
- laplacian = cv2.subtract(gaussian_pyramid_orange[i-1], gaussian_expanded)
- lp_orange.append(laplacian)
- apple_orange_pyramid = []
- n = 0
- for apple_lap, orange_lap in zip(lp_apple, lp_orange):
- n += 1
- cols, rows, channels = apple_lap.shape
- laplacian = np.hstack((apple_lap[:, 0:int(cols/2)], orange_lap[:, int(cols/2):]))
- apple_orange_pyramid.append(laplacian)
- cv2.imshow(str(n), laplacian)
- apple_orange_reconstruct = apple_orange_pyramid[0]
- for i in range(1, 6):
- apple_orange_reconstruct = cv2.pyrUp(apple_orange_reconstruct)
- apple_orange_reconstruct = cv2.add(apple_orange_pyramid[i], apple_orange_reconstruct)
- cv2.imshow('reconstruct', apple_orange_reconstruct)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement