Opencv remap returns squeezed image rather than slightly offsetted

70 Views Asked by At

I have a "distort.png" image in which the "R,G" Channels holding motion vectors (Original Position offsetted by 10 pixels) I'm using remap to transform the image into the new location with the following snippet but I get a weirdly squeezed image instead a translated one. Any thoughts?

import cv2

distort = cv2.imread(r"D:\distort.png").astype(np.float32)
src = cv2.imread(r"D:\taj.png")

map_x = distort[:, :, 1].copy()
map_y = distort[:, :, 2].copy()

remapped_image = cv2.remap(src, map_x, map_y, interpolation=cv2.INTER_LINEAR)

cv2.imshow('Original Image', remapped_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

However the image seems to be distorted:

enter image description here

and supposed to look like this (translated by 10pixels in x and y):

enter image description here

Here is the source image "taj.png"

enter image description here

And the source distort (motion vector) file

enter image description here

0

There are 0 best solutions below