darsia.GeneralizedPerspectiveTransformation#
- class GeneralizedPerspectiveTransformation[source]#
Bases:
BaseTransformationCombination 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.
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
Scaling matrix for perspective transformation
Translation vector for perspective transformation
Scaling vector for perspective transformation
Stretch vector for stretch transformation
Offsett from center for stretch transformation
Bulge vector for bulge transformation
Offsett from center for bulge transformation
Default parameters for generalized perspective transformation
input_dtypeType of input for generalized perspective transformation
output_dtypeType of output for generalized perspective transformation
input_array_dtypeType of input arrays for generalized perspective transformation
output_array_dtypeType of output arrays for generalized perspective transformation
- call_array(x)[source]#
Application of generalized perspective to coordinate array.
- Parameters:
- x
np.ndarray,Coordinate,VoxelorcorrespondingArrayofsuch Point to be transformed, type must match predefined input type.
- x
- Returns:
output_dtypeoroutput_array_dtypeWarped 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_src
CoordinateArray,VoxelArrayorVoxelCenterArray Source points.
- pts_dst
CoordinateArray,VoxelArrayorVoxelCenterArray Target points.
- fit_options
dict,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.
- pts_src
- Returns:
scipy.optimize.OptimizeResultThe optimisation result.
- inverse_array(x)[source]#
Evaluation of inverse generalized perspective to coordinate array.
- Parameters:
- x
np.ndarray,Coordinate,VoxelorcorrespondingArrayofsuch Point to be transformed, type must match predefined input type.
- x
- Returns:
output_dtypeoroutput_array_dtypeWarped point in predefined output type.
- set_parameters_as_vector(parameters)[source]#
Set parameters of generalized perspective transformation.
- Parameters:
- parameters
np.array Parameters of generalized perspective transformation.
- parameters
- 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