bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / transform / _geometric / ProjectiveTransform
ABCMeta
skimage.transform._geometric:ProjectiveTransform
source: /dev/scikit-image/src/skimage/transform/_geometric.py :937
Signature
def ProjectiveTransform ( matrix = None , * , dimensionality = None ) Members
-
__add__ -
__array__ -
__call__ -
__nice__ -
__repr__ -
__str__ -
_check_dims -
_estimate -
estimate -
from_estimate -
identity
Summary
Projective transformation.
Extended Summary
Apply a projective transformation (homography) on coordinates.
For each homogeneous coordinate , its target position is calculated by multiplying with the given matrix, , to give :
[[a0 a1 a2] [b0 b1 b2] [c0 c1 1 ]].
E.g., to rotate by theta degrees clockwise, the matrix should be
[[cos(theta) -sin(theta) 0] [sin(theta) cos(theta) 0] [0 0 1]]
or, to translate x by 10 and y by 20
[[1 0 10] [0 1 20] [0 0 1 ]].
Parameters
matrix: (D+1, D+1) array_like, optionalHomogeneous transformation matrix.
dimensionality: int, optionalFallback number of dimensions when
matrixnot specified.
Attributes
params: (D+1, D+1) arrayHomogeneous transformation matrix.
Examples
import numpy as np import skimage as ski✓
tform = ski.transform.ProjectiveTransform(np.diag([2., 3., 1.])) tform.params✓
src = np.array([[150, 150], [250, 100], [150, 200]]) dst = np.array([[200, 200], [300, 150], [150, 400]]) tform = ski.transform.ProjectiveTransform.from_estimate(src, dst) np.allclose(tform.params, [[ -16.56, 5.82, 895.81], [ -10.31, -8.29, 2075.43], [ -0.05, 0.02, 1. ]], atol=0.01)✓
img = ski.data.astronaut() warped = ski.transform.warp(img, inverse_map=tform.inverse)✓
if tform: print("Estimation succeeded.") bad_src = np.ones((3, 2)) bad_tform = ski.transform.ProjectiveTransform.from_estimate( bad_src, dst) if not bad_tform: print("Estimation failed.")✓
bad_tform.params # doctest: +IGNORE_EXCEPTION_DETAIL
✓Aliases
-
skimage.transform.ProjectiveTransform