Calculates the inverse quadratic distortion function given squared radii.
tfg.rendering.camera.quadratic_radial_distortion.undistortion_factor(
distorted_squared_radius: type_alias.TensorLike,
distortion_coefficient: type_alias.TensorLike,
num_iterations: int = 5,
name: str = 'quadratic_radial_distortion_undistortion_factor'
) -> Tuple[tf.Tensor, tf.Tensor]
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
.
Note |
In the following, A1 to An are optional batch dimensions, which must be
broadcast compatible.
|
Args |
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".
|
Returns |
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.
|