3

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.

David
  • 107
  • 5
  • Have you solved this, David? – papabiceps Sep 19 '19 at 09:45
  • Not really. I still don't know how it is done. I've found some info, e.g. in SimpleITK there is a class called [InverseDisplacementFieldImageFilter](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1InverseDisplacementFieldImageFilter.html). In the description you can find a spline based technique. However, I don't know whether classes like DisplacementFieldTransform or WarpImageFilter in SimpleITK use this method when they warp images using displacement fields. – David Oct 09 '19 at 15:52
  • If you are still looking for a solution and comments on this, I had to address the same problem lately and submitted my solution to a similar question there: https://stackoverflow.com/a/65566295/1560876 – pthibault Jan 05 '21 at 19:22

1 Answers1

0

What you might be looking for is bilinear interpolation.

  • Thank you for the answer. The problem with bilinear interpolation is how I should find the points I can use for interpolation. E.g.: with forward mapping I want to calculate J(12,25). Maybe I need to interpolate from J(11.5,24.10),J(15.6,21),J(10.6,25.1),J(12.9,26) because these would be the closest neighbours in J in this (made up) example. How do I find out these are the closest points from a list of coordinates? Is there a fast way to do this (maybe sorting+search)? Is there possibly a better way to approach this whole problem or is this the correct approach? – David Mar 16 '19 at 00:41