darsia.GeneralizedPerspectiveTransformation#

class GeneralizedPerspectiveTransformation[source]#

Bases: BaseTransformation

Combination of perspective map, bulge and stretch for 2d images.

Following the paradigm of phyisical image, generalized perspective transforms use physical parameters, and map from physical coordinates to coordinates. Thus, coordinate systems attached to images are paramount in translating to the associated voxel space.

Initialize generalized perspective transformation.

The default parameters are set to the identity transformation.

Methods

call_array(x)

Application of generalized perspective to coordinate array.

fit(pts_src, pts_dst[, fit_options])

Fit the inverse generalised perspective transformation.

inverse(x)

Apply inverse transformation to array.

inverse_array(x)

Evaluation of inverse generalized perspective to coordinate array.

set_dtype(pts_src, pts_dst)

Set array input and output type for generalized perspective transformation.

set_parameters_as_vector(parameters)

Set parameters of generalized perspective transformation.

Attributes

A

Scaling matrix for perspective transformation

b

Translation vector for perspective transformation

c

Scaling vector for perspective transformation

stretch_factor

Stretch vector for stretch transformation

stretch_center_off

Offsett from center for stretch transformation

bulge_factor

Bulge vector for bulge transformation

bulge_center_off

Offsett from center for bulge transformation

default_parameters

Default parameters for generalized perspective transformation

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 generalized perspective to coordinate array.

Parameters:
xnp.ndarray, Coordinate, Voxel or corresponding Array of such

Point to be transformed, type must match predefined input type.

Returns:
output_dtype or output_array_dtype

Warped point in predefined output type.

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

Fit the inverse generalised perspective transformation.

Also fixes the types of the input and output points; later evaluations of the transformation must use the same types. The forward evaluation is currently not implemented.

Parameters:
pts_srcCoordinateArray, VoxelArray or VoxelCenterArray

Source points.

pts_dstCoordinateArray, VoxelArray or VoxelCenterArray

Target points.

fit_optionsdict, optional

"coordinatesystem_dst" (darsia.CoordinateSystem) – coordinate system of the target points. "maxiter" (int) – maximum optimisation iterations. "tol" (float) – optimisation tolerance. "strategy" (list) – optimisation strategies to apply.

Returns:
scipy.optimize.OptimizeResult

The optimisation result.

inverse_array(x)[source]#

Evaluation of inverse generalized perspective to coordinate array.

Parameters:
xnp.ndarray, Coordinate, Voxel or corresponding Array of such

Point to be transformed, type must match predefined input type.

Returns:
output_dtype or output_array_dtype

Warped point in predefined output type.

set_parameters_as_vector(parameters)[source]#

Set parameters of generalized perspective transformation.

Parameters:
parametersnp.array

Parameters of generalized perspective transformation.

A#

Scaling matrix for perspective transformation

b#

Translation vector for perspective transformation

bulge_center_off#

Offsett from center for bulge transformation

bulge_factor#

Bulge vector for bulge transformation

c#

Scaling vector for perspective transformation

default_parameters#

Default parameters for generalized perspective transformation

stretch_center_off#

Offsett from center for stretch transformation

stretch_factor#

Stretch vector for stretch transformation