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 points are assumed to be with shape (…, input_dim) or (input_dim, …), depending on the value of transpose.

The output transformed_points will have shape (…, output_dim) if transpose is False, or (output_dim, …) if transpose is True.

Note

The points is converted to a numpy array of dtype=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 dx or dp are set to True, respectively.

The output will be a TransformResult object 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 transpose is True).

  • 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:

TransformResult

Developer Notes#

The subclasses must implement the _transform method to apply the transformation to the input points.

The _transform method 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) if dx is True, otherwise None.

    • jacobian_dp: The Jacobian matrix with respect to the parameters of the transformation of shape (n_points, output_dim, n_params) if dp is True, otherwise None.