pycvcam.Transform.transform#

Transform.transform(points, *, transpose=False, dx=False, dp=False, **kwargs)[source]#

Apply the transformation to the given points from input space to output space.

The input points are assumed to have shape (..., input_dim) or (input_dim, ...) depending on the transpose flag.

The output points will have shape (..., output_dim) if transpose=False, or (output_dim, ...) if transpose=True.

Note

The input points are automatically converted to a NumPy array of type float64.

Parameters:
  • points (ArrayLike) – Input points to be transformed. Shape (..., input_dim) or (input_dim, ...) if transpose=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 with respect to the input points. Default is False.

  • dp (bool, optional) – If True, compute the Jacobian with respect to the parameters. Default is False.

  • **kwargs – Additional arguments passed to the underlying _transform method.

Returns:

Contains the transformed points and the Jacobian matrices (if requested).

Return type:

TransformResult

Jacobians#

Two Jacobian matrices can optionally be computed:

  • dx: Jacobian of the transformed points with respect to the input points. Shape: (..., output_dim, input_dim) Example:

    jacobian_dx[..., 0, 0]  # ∂X_o/∂X_i
    jacobian_dx[..., 0, 1]  # ∂X_o/∂Y_i
    jacobian_dx[..., 1, 0]  # ∂Y_o/∂X_i
    jacobian_dx[..., 1, 1]  # ∂Y_o/∂Y_i
    
  • dp: Jacobian of the transformed points with respect to the transformation parameters. Shape: (..., output_dim, n_params) Example:

    jacobian_dp[..., 0, 0]  # ∂X_o/∂λ_1
    jacobian_dp[..., 0, 1]  # ∂X_o/∂λ_2
    jacobian_dp[..., 1, 0]  # ∂Y_o/∂λ_1
    jacobian_dp[..., 1, 1]  # ∂Y_o/∂λ_2
    

The Jacobians are only computed if dx or dp are True.

Developer Notes#

Subclasses must implement the _transform method. This method should:

  1. Accept a NumPy array of shape (n_points, input_dim).

  2. Return three arrays:

    • transformed_points: shape (n_points, output_dim).

    • jacobian_dx: shape (n_points, output_dim, input_dim) if dx=True, else None.

    • jacobian_dp: shape (n_points, output_dim, n_params) if dp=True, else None.