magpack.image_utils.non_affine_transform#

non_affine_transform(data, matrix, order=1)#

Applies a non-affine transformation to the input image.

Parameters:
datanp.ndarray

The image to be transformed.

matrixnp.ndarray

The non-affine transformation matrix.

orderint

The interpolation order of the non-affine transformation (between 0 and 5).

Returns:
np.ndarray

The transformed image.

Notes

The matrix describing the non-affine transformation is given by:

\[\begin{split}\begin{pmatrix} x' \\ y' \\ z' \end{pmatrix} = \begin{pmatrix} \text{ScaleX} & \text{SkewX} & \text{TransX} \\ \text{SkewY} & \text{ScaleY} & \text{TransY} \\ \text{PerspX} & \text{PerspY} & \text{Norm} \\ \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}\end{split}\]

and then perspective in the final image is achieved through

\[X = x' / z',\quad Y = y' / z'\]