pycvcam.core.Transform.transform#
- Transform.transform(points, *, transpose=False, dx=False, dp=False, **kwargs)[source]#
Transform the given points using the transformation from \(\mathbb{R}^{\text{input_dim}}\) to \(\mathbb{R}^{\text{output_dim}}\).
The given points
pointsare assumed to be with shape (…, input_dim) or (input_dim, …), depending on the value oftranspose.The output
transformed_pointswill have shape (…, output_dim) iftransposeisFalse, or (output_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 (…, output_dim, input_dim) matrix where:
jacobian_dx[..., 0, 0] # ∂X_o/∂X_i -> Jacobian of the coordinates X_o with respect to the coordinates X_i. jacobian_dx[..., 0, 1] # ∂X_o/∂Y_i ... jacobian_dx[..., 1, 0] # ∂Y_o/∂X_i -> Jacobian of the coordinates Y_o with respect to the coordinates X_i. jacobian_dx[..., 1, 1] # ∂Y_o/∂Y_i ...
The Jacobian matrice with respect to the parameters is a (…, output_dim, n_params) matrix where:
jacobian_dp[..., 0, 0] # ∂X_o/∂λ_1 -> Jacobian of the coordinates X_o with respect to the first parameter λ_1. jacobian_dp[..., 0, 1] # ∂X_o/∂λ_2 ... jacobian_dp[..., 1, 0] # ∂Y_o/∂λ_1 -> Jacobian of the coordinates Y_o with respect to the first parameter λ_1. jacobian_dp[..., 1, 1] # ∂Y_o/∂λ_2 ...
The Jacobian matrices are computed only if
dxordpare set to True, 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 (…, input_dim) (or (input_dim, …) if
transposeisTrue).transpose (bool, optional) – If True, the input points are transposed to shape (input_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
_transformmethod to apply the transformation to the input points.The
_transformmethod should:take the input points as a numpy array of shape (n_points, input_dim)
return 3 numpy arrays:
transformed_points: The transformed points of shape (n_points, output_dim).jacobian_dx: The Jacobian matrix with respect to the input points of shape (n_points, output_dim, input_dim) ifdxis True, otherwise None.jacobian_dp: The Jacobian matrix with respect to the parameters of the transformation of shape (n_points, output_dim, n_params) ifdpis True, otherwise None.