3
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ Related but in the forward direction (234688) , also my intent is to try to apply this to my other question (253252) $\endgroup$
    – flinty
    Commented Aug 14, 2021 at 13:18
  • $\begingroup$ 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. $\endgroup$ Commented Aug 14, 2021 at 22:04
  • $\begingroup$ @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. $\endgroup$
    – flinty
    Commented Aug 14, 2021 at 23:53
  • $\begingroup$ 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 (reference.wolfram.com/language/ref/ImageTransformation.html). $\endgroup$ Commented Aug 15, 2021 at 0:18
  • $\begingroup$ demonstrations.wolfram.com/ImageWarping $\endgroup$
    – Syed
    Commented Aug 16, 2021 at 19:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.