pycvcam.core.Transform.inverse_transform#
- Transform.inverse_transform(points, *, transpose=False, dx=False, dp=False, **kwargs)[source]#
Apply the inverse transformation to the given points using the transformation from \(\mathbb{R}^{\text{output_dim}}\) to \(\mathbb{R}^{\text{input_dim}}\).
The given points
pointsare assumed to be with shape (…, output_dim) or (output_dim, …), depending on the value oftranspose.The output
transformed_pointswill have shape (…, input_dim) iftransposeisFalse, or (input_dim, …) iftransposeisTrue.Note
The
pointsis converted to a numpy array ofdtype=numpy.float64.The method also computes 2 Jacobian matrices if requested:
dx: Jacobian of the transformed points with respect to the input points.dp: Jacobian of the transformed points with respect to the parameters of the transformation.
The jacobian matrice with respect to the input points is a (…, input_dim, output_dim) matrix where:
jacobian_dx[..., 0, 0] # ∂X_i/∂X_o -> Jacobian of the coordinates X_i with respect to the coordinates X_o. jacobian_dx[..., 0, 1] # ∂X_i/∂Y_o ... jacobian_dx[..., 1, 0] # ∂Y_i/∂X_o -> Jacobian of the coordinates Y_i with respect to the coordinates X_o. jacobian_dx[..., 1, 1] # ∂Y_i/∂Y_o ...
The Jacobian matrice with respect to the parameters is a (…, input_dim, n_params) matrix where:
jacobian_dp[..., 0, 0] # ∂X_i/∂λ_1 -> Jacobian of the coordinates X_i with respect to the first parameter λ_1. jacobian_dp[..., 0, 1] # ∂X_i/∂λ_2 ... jacobian_dp[..., 1, 0] # ∂Y_i/∂λ_1 -> Jacobian of the coordinates Y_i with respect to the first parameter λ_1. jacobian_dp[..., 1, 1] # ∂Y_i/∂λ_2 ...
The Jacobian matrices are computed only if
dxordpare set toTrue, respectively.The output will be a
TransformResultobject containing the transformed points and the Jacobian matrices if requested.- Parameters:
points (ArrayLike) – The input points to be transformed. Shape (…, output_dim) (or (output_dim, …) if
transposeisTrue).transpose (bool, optional) – If True, the input points are transposed to shape (output_dim, …). Default is False.
dx (bool, optional) – If True, compute the Jacobian of the transformed points with respect to the input points. Default is False.
dp (bool, optional) – If True, compute the Jacobian of the transformed points with respect to the parameters of the transformation. Default is False.
**kwargs – Additional keyword arguments for the transformation.
- Returns:
An object containing the transformed points and the Jacobian matrices if requested.
- Return type:
Developer Notes#
The subclasses must implement the _inverse_transform method to apply the inverse transformation to the input points.
The
_inverse_transformmethod should:take the input points as a numpy array of shape (n_points, output_dim)
return 3 numpy arrays:
transformed_points: The transformed points of shape (n_points, input_dim).jacobian_dx: The Jacobian matrix with respect to the input points of shape (n_points, input_dim, output_dim) ifdxisTrue, otherwise None.jacobian_dp: The Jacobian matrix with respect to the parameters of the transformation of shape (n_points, input_dim, n_params) ifdpisTrue, otherwise None.