{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / transform / _geometric / PiecewiseAffineTransform

ABCMeta

skimage.transform._geometric:PiecewiseAffineTransform

source: /dev/scikit-image/src/skimage/transform/_geometric.py :1559

Signature

def   PiecewiseAffineTransform ( )

Members

Summary

Piecewise affine transformation.

Extended Summary

Control points are used to define the mapping. The transform is based on a Delaunay triangulation of the points to form a mesh. Each triangle is used to find a local affine transform.

Attributes

affines : list of AffineTransform objects

Affine transformations for each triangle in the mesh.

inverse_affines : list of AffineTransform objects

Inverse affine transformations for each triangle in the mesh.

Examples

import numpy as np
import skimage as ski
Define a transformation by estimation:
src = [[-12.3705, -10.5075],
       [-10.7865, 15.4305],
       [8.6985, 10.8675],
       [11.4975, -9.5715],
       [7.8435, 7.4835],
       [-5.3325, 6.5025],
       [6.7905, -6.3765],
       [-6.1695, -0.8235]]
dst = [[0, 0],
       [0, 5800],
       [4900, 5800],
       [4900, 0],
       [4479, 4580],
       [1176, 3660],
       [3754, 790],
       [1024, 1931]]
tform = ski.transform.PiecewiseAffineTransform.from_estimate(src, dst)
Calling the transform applies the transformation to the points:
np.allclose(tform(src), dst)
You can apply the inverse transform:
np.allclose(tform.inverse(dst), src)
The estimation can fail - for example, if all the input or output points are the same. If this happens, you will get a transform that is not "truthy" - meaning that ``bool(tform)`` is ``False``:
if tform:
    print("Estimation succeeded.")
bad_src = [[1, 1]] * 6 + src[6:]
bad_tform = ski.transform.PiecewiseAffineTransform.from_estimate(
     bad_src, dst)
if not bad_tform:
    print("Estimation failed.")
Trying to use this failed estimation transform result will give a suitable error:
bad_tform.params  # doctest: +IGNORE_EXCEPTION_DETAIL

Aliases

  • skimage.transform.PiecewiseAffineTransform