estimate_transform
-
skimage.transform.estimate_transform(ttype, src, dst, **kwargs)
[source] -
Estimate 2D geometric transformation parameters.
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 : {‘similarity’, ‘affine’, ‘piecewise-affine’, ‘projective’, ‘polynomial’}
Type of transform.
kwargs : array or int
Function parameters (src, dst, n, angle):
1234567NAME
/
TTYPE FUNCTION PARAMETERS
'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: tform :
GeometricTransform
Transform object containing the transformation parameters and providing access to forward and inverse transformation functions.
Examples
12>>>
import
numpy as np
>>>
from
skimage
import
transform as tf
123>>>
# estimate transformation parameters
>>> src
=
np.array([
0
,
0
,
10
,
10
]).reshape((
2
,
2
))
>>> dst
=
np.array([
12
,
14
,
1
,
-
20
]).reshape((
2
,
2
))
1>>> tform
=
tf.estimate_transform(
'similarity'
, src, dst)
12>>> np.allclose(tform.inverse(tform(src)), src)
True
123>>>
# warp image using the estimated transformation
>>>
from
skimage
import
data
>>> image
=
data.camera()
1>>> warp(image, inverse_map
=
tform.inverse)
123>>>
# create transformation with explicit parameters
>>> tform2
=
tf.SimilarityTransform(scale
=
1.1
, rotation
=
1
,
... translation
=
(
10
,
20
))
1234>>>
# unite transformations, applied in order from left to right
>>> tform3
=
tform
+
tform2
>>> np.allclose(tform3(src), tform2(tform(src)))
True
Please login to continue.