I have a texture image and some uv coordinators (some float 2D vectors). Is there any method in OpenCV can automatically interpolate the image and then I can directly use these float number as the pixel coordinator and get the correct pixel value?
I think it should be possible because in some computer vision algorithms like optic flow we will always have some sub pixel value...
Remap is what you want, here is an example:
import cv2
import numpy as np
img = cv2.imread('myimage.png')
interpolated_pixel = cv2.remap(img, np.array([[2.4]], np.float32), np.array([[5.4]], np.float32), cv2.INTER_LINEAR)
print(interpolated_pixel)
You can play with different interpolation schemes, see interpolation flags
Of course you can also batch your request by providing multiple uv coordinates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With