Let's say I have an image I(x,y) and a vector field w(x,y), both sampled on the same regular grid. My goal is to warp the image according to the vector field and create output image J(u,v). This is done by mapping points (x,y) in I to points (u,v) in J. The problem is I don't know what is the easiest way implement this. I have read online that there are basically two main approaches to these kinds of problems.
Forward mapping: simply add the displacement vector to every coordinate (x,y) of image I. The problem here is that this way I would get non-integer coordinate points (u',v') on a non-regular grid in J, because w(x,y) is not necessarily integer-valued and varies from pixel-to-pixel. My question is: how can I interpolate this image to integer coordinates? For example, if I would like to calculate the pixel value of J(12,25), how do I know which sample points to use for the interpolation if the samples are not on a regular grid?
Backward mapping: find out which non-integer coordinates (x',y') in I correspond to integer coordinates (u,v) in J by applying the inverse of the transformation to coordinates (u,v). The values corresponding to the non-integer coordinates (x',y') in I can then be interpolated easily. My question is: can I apply this to my problem somehow? Can I somehow invert my displacement field? How would I find the inverse of this displacement field that maps integer values from J to non-integer values in I ?
To clarify, I am not looking for existing implementations of solutions to this problem (I know that there are for example functions in Matlab and OpenCV that can do this). I would only like to understand the theory behind it and start experimenting on my own.