pychubby.base module¶
Base classes and functions.
-
class
pychubby.base.
DisplacementField
(delta_x, delta_y)¶ Bases:
object
Represents a coordinate transformation.
-
classmethod
generate
(shape, old_points, new_points, anchor_corners=True, **interpolation_kwargs)¶ Create a displacement field based on old and new landmark points.
Parameters: - shape (tuple) – Tuple representing the height and the width of the displacement field.
- old_points (np.ndarray) – Array of shape (N, 2) representing the x and y coordinates of the old landmark points.
- new_points (np.ndarray) – Array of shape (N, 2) representing the x and y coordinates of the new landmark points.
- anchor_corners (bool) – If True, then assumed that the 4 corners of the image correspond.
- interpolation_kwargs (dict) – Additional parameters related to the interpolation.
Returns: df – DisplacementField instance representing the transformation that allows for warping the old image with old landmarks into the new coordinate space.
Return type:
-
is_valid
¶ Check whether both delta_x and delta_y finite.
-
norm
¶ Compute per element euclidean norm.
-
transformation
¶ Compute actual transformation rather then displacements.
-
warp
(img, order=1)¶ Warp image into new coordinate system.
Parameters: - img (np.ndarray) – Image to be warped. Any number of channels and dtype either uint8 or float32.
- order (int) –
- Interpolation order.
- 0 - nearest neigbours
- 1 - linear
- 2 - cubic
Returns: warped_img – Warped image. The same number of channels and same dtype as the img.
Return type: np.ndarray
-
classmethod