bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / transform / _geometric / estimate_transform
function
skimage.transform._geometric:estimate_transform
source: /dev/scikit-image/src/skimage/transform/_geometric.py :2574
Signature
def estimate_transform ( ttype , src , dst , * args , ** kwargs ) Summary
Estimate 2D geometric transformation parameters.
Extended Summary
You can determine the over-, well- and under-determined parameters with the total least-squares method.
Number of source and destination coordinates must match.
Parameters
ttype: {'euclidean', similarity', 'affine', 'piecewise-affine', 'projective', 'polynomial'}Type of transform.
kwargs: array_like or intFunction parameters (src, dst, n, angle)
NAME / TTYPE FUNCTION PARAMETERS 'euclidean' `src, `dst` 'similarity' `src, `dst` 'affine' `src, `dst` 'piecewise-affine' `src, `dst` 'projective' `src, `dst` 'polynomial' `src, `dst`, `order` (polynomial order, default order is 2)
Also see examples below.
Returns
tf: :class:`_GeometricTransform` or :class:`FailedEstimation`An instance of the requested transformation if the estimation Otherwise, we return a special
FailedEstimationobject to signal a failed estimation. Testing the truth value of the failed estimation object will returnFalse. E.g.tf = estimate_transform(...) if not tf: raise RuntimeError(f"Failed estimation: {tf}")
Examples
import numpy as np import skimage as ski✓
src = np.array([0, 0, 10, 10]).reshape((2, 2)) dst = np.array([12, 14, 1, -20]).reshape((2, 2))✓
tform = ski.transform.estimate_transform('similarity', src, dst)
✓np.allclose(tform.inverse(tform(src)), src)
✓image = ski.data.camera()
✓tform2 = ski.transform.SimilarityTransform(scale=1.1, rotation=1, translation=(10, 20))✓
tform3 = tform + tform2 np.allclose(tform3(src), tform2(tform(src)))✓
if tform: print("Estimation succeeded.") bad_src = np.ones((2, 2)) bad_tform = ski.transform.estimate_transform('similarity', bad_src, dst) if not bad_tform: print("Estimation failed.")✓
bad_tform.params # doctest: +IGNORE_EXCEPTION_DETAIL
✓Aliases
-
skimage.transform.estimate_transform