darsia.AffineTransformation#

class AffineTransformation(dim)[source]#

Bases: BaseTransformation

Affine map, restricted to translation, scaling, rotation, resulting in conservation of angles.

Constructor for identity encoded as affine transformation.

Parameters:
dimint

Dimension of the Euclidean space.

Raises:
ValueError

If not sufficient input data is provided.

ValueError

If dimension not 2 or 3.

Methods

call_array(x)

Application of map to arrays.

fit(pts_src, pts_dst[, fit_options])

Least-squares fit of the forward and inverse map.

inverse(x)

Apply inverse transformation to array.

inverse_array(x)

Application of inverse of the map to arrays.

set_dtype(pts_src, pts_dst)

Set array input and output type for generalized perspective transformation.

set_parameters([translation, scaling, rotation])

Set-access of parameters of map.

set_parameters_as_vector(parameters)

Wrapper for set_parameters.

Attributes

dim

Dimension of the Euclidean space.

translation

Translation vector.

scaling

Scaling factor.

rotation

Rotation matrix.

rotation_inv

Inverse of rotation matrix.

isometry

Flag storing whether the underlying transformation is restricted to isometry.

input_dtype

Type of input for generalized perspective transformation

output_dtype

Type of output for generalized perspective transformation

input_array_dtype

Type of input arrays for generalized perspective transformation

output_array_dtype

Type of output arrays for generalized perspective transformation

call_array(x)[source]#

Application of map to arrays.

Parameters:
xnp.ndarray

(collection of) dim-dimensional Euclidean vector.

Returns:
np.ndarray

Function values of affine map.

fit(pts_src, pts_dst, fit_options={})[source]#

Least-squares fit of the forward and inverse map.

Parameters:
pts_srcVoxelArray or CoordinateArray

Source points.

pts_dstVoxelArray or CoordinateArray

Target points.

fit_optionsdict, optional

"preconditioning" (bool) – precondition the optimisation with a better initial translation guess. "tol" (float) – optimisation tolerance. "maxiter" (int) – maximum optimisation iterations. "isometry" (bool) – whether the transformation is an isometry.

Returns:
bool

Whether the fit succeeded.

inverse_array(x)[source]#

Application of inverse of the map to arrays.

Parameters:
xnp.ndarray

(collection of) dim-dimensional Euclidean vector,

Returns:
np.ndarray

Function values of affine inverse map.

set_parameters(translation=None, scaling=None, rotation=None)[source]#

Set-access of parameters of map.

Parameters:
translationarray, optional

Translation vector.

scalingfloat, optional

Scaling value.

rotationarray, optional

Rotation angles in radians for the rotation around the x, y, and z axis, respectively. In 2d, the length is 1. In 3d, the length is 3.

set_parameters_as_vector(parameters)[source]#

Wrapper for set_parameters.

Parameters:
parametersarray

All parameters concatenated as array. In 2d, the length is either 3 (translation, rotation) or 4 (translation, scaling, rotation). In 3d, the length is either 6 (translation, rotation) or 7 (translation, scaling, rotation).

dim#

Dimension of the Euclidean space.

isometry#

Flag storing whether the underlying transformation is restricted to isometry.

rotation#

Rotation matrix.

rotation_inv#

Inverse of rotation matrix.

scaling#

Scaling factor.

translation#

Translation vector.