tfg.rendering.camera.quadratic_radial_distortion.undistortion_factor

Calculates the inverse quadratic distortion function given squared radii.

Given a vector describing a location in camera space in homogeneous coordinates (x/z, y/z, 1), after distortion has been applied, these become (x'/z, y'/z, 1). distorted_squared_radius is (x'/z)^2 + (y'/z)^2. undistortion_factor multiplies x'/z and y'/z to obtain the undistorted projective coordinates x/z and y/z. The undustortion factor in this function is derived from a quadratic. distortion function, where the distortion factor equals 1.0 + distortion_coefficient * squared_radius.

In the following, A1 to An are optional batch dimensions, which must be broadcast compatible.

distorted_squared_radius A tensor of shape [A1, ..., An, H, W] containing the value of projective coordinates (x/z)^2 + (y/z)^2. For each pixel it contains the squared distance of that pixel to the center of the image plane. We use distorted_squared_radius rather than the distorted radius itself to avoid an unnecessary sqrt, which may introduce gradient singularities. The non-negativity of distorted_squared_radius is only enforced in debug mode.
distortion_coefficient A scalar or a tensor of shape [A1, ..., An], which contains the distortion coefficients of each image.
num_iterations Number of Newton-Raphson iterations to calculate the inverse distortion function. Defaults to 5, which is on the high-accuracy side.
name A name for this op. Defaults to "quadratic_radial_distortion_undistortion_factor".

undistortion A tensor of shape [A1, ..., An, H, W] containing the correction factor that should multiply the distorted projective coordinates (x'/z) and (y'/z) to obtain the undistorted ones.
overflow_mask A bool tensor of shape [A1, ..., An, H, W], True where distorted_squared_radius is beyond the range where the distortion function is monotonically increasing. Wherever overflow_mask is True, undistortion_factor's value is meaningless.