Indexing with mapping tensor

Hello,

I have the following two tensors:

  • input RGB image of shape (h,w,c) e.g. (224,224,3)

  • Mapping of shape (h,w, 2) e.g. (224, 224, 2) which provides for every pixel of the image coordinates (x,y)

I want to create now a new output image tensor that contains on the indexes (x,y) the value of the input image. In other words the output should contain on the positions, given by the mapping tensor, the color values of the input image.

How would one do the indexing?