Querying an image with bilinear interpolation e.e. finding RGB value in the fractional coordinates using Pytorch
I have a input T1 of size (1,256,256,3) i.e. images/grid of batch size 1. I have another tensor T2 of size (1, N, 2) i.e. tensor consisting of coordinates i.e. [ [10.5 , 200.787], [150.568, 190.456], …]. How do I compute functional values (using bilinear interpolation) of coordinates in T2 from T1 data?

Thanks for any help

I have tested the same functionality using tensorflow with the function "tf.contrib.resampler.resampler"

try grid_sample:

torch.nn.functional.grid_sample(input, grid, mode='bilinear', padding_mode='zeros')


Given an input and a flow-field grid, computes the output using input values and pixel locations from grid.

For each output location output[n, :, h, w], the size-2 vector grid[n, h, w] specifies input pixel locations x and y, which are used to interpolate the output value output[n, :, h, w]. mode argument specifies nearest or bilinear interpolation method to sample the input pixels.

coordinate should be in range of [-1, 1]. This is because the pixel locations are normalized by the input spatial dimensions.

sampler git example 
pytorch documentation
