3

ImageDisplacements provides a way to calculate the displacements between two images (e.g for optical flow purposes) and return a two channel image containing the dx,dy displacements.

What should I do if I already have a two channel image of displacements and want to warp an existing image? i.e how can I use an image to warp another image?

Suppose I have this warped image newimg:

warped

... which originally came from:

testimg = ImageResize[ExampleData[{"TestImage", "House2"}], 512];

Without knowing the transformation, but given an optical flow image:

ImageAdjust@Image[
  First@ImageDisplacements[{testimg, newimg}]
 ]

optical flow

... how can I use this to "unwarp" the distorted image efficiently back into something resembling the original?

flinty
  • 25,147
  • 2
  • 20
  • 86
  • Related but in the forward direction (234688) , also my intent is to try to apply this to my other question (253252) – flinty Aug 14 '21 at 13:18
  • I would compute corresponding feature points in the two images then estimate a two-dimensional interpolation function, then apply it to the image you seek to alter. – David G. Stork Aug 14 '21 at 22:04
  • @DavidG.Stork I don't have two images to get correspondences from - I only have the warped image, and the displacement image (colourful thing at the end) - the original unwarped image which is the desired result has only been provided for the purposes of calculating the distortion map and measuring the quality. – flinty Aug 14 '21 at 23:53
  • Then I would fit the displacement image with a two dimensional function ($\Delta x , \Delta y)$ as a function of position, then use ImageTransformation applied to your given image (https://reference.wolfram.com/language/ref/ImageTransformation.html). – David G. Stork Aug 15 '21 at 00:18
  • https://demonstrations.wolfram.com/ImageWarping/ – Syed Aug 16 '21 at 19:09

0 Answers0