You are here: User Guide > NukeX > Working with Lens Distortion > Calculating the Distortion on One Image and Applying it to Another

Calculating the Distortion on One Image and Applying it to Another

You can use the LensDistortion node to analyze the distortion on one image or grid, and then apply that distortion to another image. Do the following:

1.   Use the LensDistortion node to analyze an image or grid to get the distortion parameters. Make sure Output Type is set to Image on the LensDistortion tab of the LensDistortion node. Check that the resulting image looks undistorted.
2.   Set Output Type to Displacement.

In this mode, the LensDistortion node leaves the input image alone and writes the pixel displacements that correspond to the calculated distortion to the UV channels. These appear as forward motion channels in the Viewer’s channel dropdown. The displacement is in the format used by the STMap node.

3.   Uncheck Undistort to apply distortion instead of removing it.
4.   Select Transform > STMap in the Nuke Toolbar to insert an STMap node in the Node Graph. Connect the STMap node’s stmap input to the LensDistortion node.
5.   Import an image you want to distort with the distortion calculated in step 1. Connect that image to the src input of the STMap node.
6.   In the STMap controls, select motion from the UV channels dropdown menu. This should now apply the distortion from the LensDistortion node’s input to the STMap node’s src input.