Bilinear Interpolation at random locations in an image

Hi everyone,

Let’s say I have data consisting of batches of images, resulting in a shape of [batch_size, channels, h, w]. I also have batches of x-y coordinates, which are not integer values -> [batch_size, num_points, 2].

What I want to do now is to get a resulting tensor of size [batch_size, channels, num_points] which are the bilinear interpolated values for the given float x-y coordinates.

Is there a respective function in pytorch? I have only found sampling methods, but this is not what I want.

Thanks a lot!

1 Like

I think grid_sample should be suitable. Could you try that out and see if it’s working for you?

Hi, did you solve it? I hanve the same quesiton…