bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / transform / _geometric / SimilarityTransform
ABCMeta
skimage.transform._geometric:SimilarityTransform
source: /dev/scikit-image/src/skimage/transform/_geometric.py :2073
Signature
def SimilarityTransform ( matrix = None , * , scale = None , rotation = None , translation = None , dimensionality = None ) Members
Summary
Similarity transformation.
Extended Summary
Has the following form in 2D
X = a0 * x - b0 * y + a1 = = s * x * cos(rotation) - s * y * sin(rotation) + a1 Y = b0 * x + a0 * y + b1 = = s * x * sin(rotation) + s * y * cos(rotation) + b1
where s is a scale factor and the homogeneous transformation matrix is
[[a0 -b0 a1] [b0 a0 b1] [0 0 1 ]]
The similarity transformation extends the Euclidean transformation with a single scaling factor in addition to the rotation and translation parameters.
The implicit parameters are applied in the following order:
Scale;
Rotation;
Translation.
Parameters
matrix: array_like of shape (K, K), with K=D+1 (D being the dimensionality), optionalHomogeneous transformation matrix.
scale: float, optionalScale factor. Implemented only for 2D and 3D.
rotation: float, optionalRotation angle, clockwise, as radians. Implemented only for 2D and 3D. For 3D, this is given in ZYX Euler angles.
translation: array_like of shape (D,), optionalx, y[, z] translation parameters. Implemented only for 2D and 3D.
dimensionality: int, optionalThe dimensionality of the transform, corresponding to
Dabove. Ignored ifmatrixis not None, and set tomatrix.shape[0] - 1. Otherwise, must be one of 2 or 3.
Attributes
params: ndarray of shape (K, K), with K=D+1 (D being the dimensionality)Homogeneous transformation matrix.
Examples
import numpy as np import skimage as ski✓
tform = ski.transform.SimilarityTransform(np.diag([2., 3., 1.])) tform.params✓
tform = ski.transform.SimilarityTransform( rotation=0.2, translation=[1, 2]) np.round(tform.params, 2)✓
src = np.array([[150, 150], [250, 100], [150, 200]]) dst = np.array([[200, 200], [300, 150], [150, 400]]) tform = ski.transform.SimilarityTransform.from_estimate(src, dst) np.allclose(tform.params, [[ 1.79, 0.21, -142.86], [-0.21, 1.79, 21.43], [ 0. , 0. , 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.SimilarityTransform.from_estimate( bad_src, dst) if not bad_tform: print("Estimation failed.")✓
bad_tform.params # doctest: +IGNORE_EXCEPTION_DETAIL
✓Aliases
-
skimage.transform.SimilarityTransform