pysdic.ZernikeDistortion._apply#

ZernikeDistortion._apply(normalized_points, *, dx=False, dp=False)[source]#

Compute the transformation from the normalized points to the distorted points.

\[\begin{split}\vec{x}_d = \vec{x}_n + \sum_{n, m} \vec{C}_{n,m} Z_{n,m}(\rho, \theta) \qquad \text{with} \qquad \vec{C}_{n,m} = \begin{bmatrix} C^{x}_{n,m} \\ C^{y}_{n,m} \end{bmatrix}\end{split}\]

The Jacobian with respect to the normalized points is:

\[\frac{\partial \vec{x}_d}{\partial \vec{x}_n} = I_2 + \sum_{n, m} \vec{C}_{n,m} \begin{bmatrix} \frac{\partial Z_{n,m}}{\partial x_n} & \frac{\partial Z_{n,m}}{\partial y_n} \end{bmatrix}\]

where the derivatives of the Zernike polynomials with respect to the cartesian coordinates are given by pyzernike. The Jacobian with respect to the coefficients is:

\[\frac{\partial x_d}{\partial C^{x}_{n,m}} = \frac{\partial y_d}{\partial C^{y}_{n,m}} = Z_{n,m}(\rho, \theta), \qquad \frac{\partial x_d}{\partial C^{y}_{n,m}} = \frac{\partial y_d}{\partial C^{x}_{n,m}} = 0\]

Note

The points outside the ellipse of definition are distorted to NaN.

Note

With a polynomials_cache, the polynomials at the same points (and the same ellipse) are computed once and reused (see ZernikePolynomialsCache).

Parameters:
  • normalized_points (numpy.ndarray) – The normalized points. Shape (n_points, 2).

  • dx (bool, optional (default: False)) – If True, the Jacobian with respect to the normalized points is computed.

  • dp (bool, optional (default: False)) – If True, the Jacobian with respect to the distortion parameters is computed.

Returns:

  • distorted_points (numpy.ndarray) – The distorted points. Shape (n_points, 2).

  • jacobian_dx (Optional[numpy.ndarray]) – The Jacobian of the distorted points with respect to the normalized points. Shape (n_points, 2, 2) if dx=True, otherwise None.

  • jacobian_dp (Optional[numpy.ndarray]) – The Jacobian of the distorted points with respect to the distortion parameters. Shape (n_points, 2, n_parameters) if dp=True, otherwise None.

Return type:

Tuple[ndarray, ndarray | None, ndarray | None]