Data Class TransformResult#

class TransformResult(transformed_points, jacobian_dx=None, jacobian_dp=None, transpose=False)[source]#

A class to represent the result of a transformation.

This class is used to store the results of a transformation, including the transformed points and the Jacobian matrices.

See also

For a transformation from \(\mathbb{R}^{\text{input dim}}\) to \(\mathbb{R}^{\text{output dim}}\), the input points are assumed to have shape (…, input_dim) and the output points will have shape (…, output_dim).

The Jacobian matrices are computed with respect to the input points and the parameters of the transformation:

  • The Jacobian with respect to the input points has shape (…, output_dim, input_dim).

  • The Jacobian with respect to the parameters has shape (…, output_dim, n_params), where n_params is the number of parameters of the transformation.

Note

If transpose is set to True during the transformation, the output points will have shape (output_dim, …) instead of (…, output_dim), same for the Jacobian matrices (ie. shape (output_dim, …, input_dim) and (output_dim, …, n_params) respectively).

Parameters:
transformed_points#

The transformed points after applying the transformation. Can be accessed using the x alias. Shape (…, output_dim).

Type:

numpy.ndarray

jacobian_dx#

The Jacobian matrix with respect to the input points. Can be None if not computed and accessed using the dx alias. Shape (…, output_dim, input_dim).

Type:

Optional[numpy.ndarray]

jacobian_dp#

The Jacobian matrix with respect to the parameters of the transformation. Can be None if not computed and accessed using the dp alias. Shape (…, output_dim, n_params).

Type:

Optional[numpy.ndarray]

transpose#

If True, the output points and Jacobian matrices will have shape (output_dim, …) instead of (…, output_dim). True if set during the transformation, otherwise False.

Type:

bool

Jacobians Short-hand Notations#

Short-hand notations for the Jacobian matrices can be added to the TransformResult class using the add_jacobian() method. This allows adding custom views of the jacobian_dp matrix with respect to the parameters of the transformation.

result = TransformResult(transformed_points, jacobian_dx, jacobian_dp)
result.add_jacobian("dk", start=0, end=2, doc="Custom Jacobian view for the first two parameters related to k1 and k2")

result.jacobian_dk  # Returns a view of the jacobian_dp matrix for parameters k1 and k2, i.e., jacobian_dp[..., 0:2]

Aliases for Transformed Points#

Aliases can be added to the TransformResult class to provide more convenient access to the transformed points, depending on the context of the transformation, via the add_alias() method.

result = TransformResult(transformed_points, jacobian_dx, jacobian_dp)
result.add_alias("image_points")

result.image_points  # Returns the transformed_points array

By default x is an alias for the transformed points, but additional aliases can be added using the add_alias() method. This allows to access the transformed points using a more convenient name depending on the context of the transformation (e.g., “image_points” for transformations related to image processing, “world_points” for transformations related to 3D world coordinates, etc.).