TransformModal Class#

Note

See the main pycvcam.Transform documentation for more details on how to use transformations.

TransformModal Class#

class TransformModal(transform, modes)[source]#

A class representing a reduced-parameter version of a transformation where the parameters are constrained to lie in a lower-dimensional subspace.

Consider a transformation \(T\) with \(n\) parameters. In some applications, the parameters are assumed to evolve only within a subspace of dimension \(m\) with \(m < n\).

This subspace is defined by a set of basis vectors called modes.

For example, suppose a transformation has 10 parameters, but only 2 effective degrees of freedom are relevant for the application. A TransformModal can then be constructed by defining two modes \(m_1\) and \(m_2\), which are linear combinations of the original parameters.

\[ \begin{align}\begin{aligned}m_1 = a_{11} p_1 + a_{12} p_2 + \dots + a_{1n} p_n\\m_2 = a_{21} p_1 + a_{22} p_2 + \dots + a_{2n} p_n\end{aligned}\end{align} \]

where \(a_{ij}\) are the coefficients defining the linear combinations of the original parameters \(p_i\).

The modal transformation is then parameterized by only \(m\) coefficients \(\alpha_1, \dots, \alpha_m\) such that the original parameters are expressed as

\[p = \alpha_1 m_1 + \alpha_2 m_2\]
\[p = M^T \alpha\]

The transformation is applied by reconstructing the full parameter vector from the modal coefficients and evaluating the original transformation.

Important

Note that modifying the parameters or constants of the individual transformations after creating the modal transformation will affect the behavior of the modal transformation, since the modal transformation does not create independent copies of the parameters and constants.

Moreover, modifying the parameters or constants of the modal transformation will modify the parameters and constants of the original transformation, since they are shared.

Warning

If the number of parameters of the original transformation changes, the modal transformation will become broken since the modes will no longer be compatible with the original transformation.

Parameters:
  • transform (Transform) – The original transformation from which the modal representation is derived.

  • modes (ArrayLike) –

    Basis vectors defining the parameter subspace.

    Shape (m, n) where: - m is the number of modes - n is the number of parameters of the original transformation.

Accessing sub-Transform object#

The following attributes and methods are available for accessing the individual Transform objects that make up a TransformModal

TransformModal.get_transform()

[Get] The original transformation from which the modal representation is derived.

Modified methods of TransformModal objects#

The following methods are modified for TransformModal objects to handle the composition of multiple transformations:

TransformModal.copy()

Create a copy of the TransformModal object by copying the base transformations and the modes.

TransformModal.from_dict(data)

Create a TransformModal object from a dictionary.

TransformModal.to_dict()

Serialize the transformation modal to a dictionary.

TransformModal.__repr__()

String representation of the Transform class.

Performing transformations with TransformModal objects#

TransformModal._transform(points, *[, dx, dp])

Apply the modal transformation to a set of input points.

TransformModal._inverse_transform(points, *)

Apply the inverse of the modal transformation to a set of input points.