Geometric and other transformations, e.g., rotations, Radon transform.
Geometric transformation:
These transforms change the shape or position of an image.
They are useful for tasks such as image registration,
alignment, and geometric correction.
Examples: AffineTransform,
ProjectiveTransform,
EuclideanTransform.
Image resizing and rescaling:
These transforms change the size or resolution of an image.
They are useful for tasks such as down-sampling an image to
reduce its size or up-sampling an image to increase its resolution.
Examples: resize(),
.
rescale()
Feature detection and extraction:
These transforms identify and extract specific features or
patterns in an image. They are useful for tasks such as object
detection, image segmentation, and feature matching.
Examples: hough_circle(),
pyramid_expand(),
radon().
Image transformation:
These transforms change the appearance of an image without changing its
content. They are useful for tasks such a creating image mosaics,
applying artistic effects, and visualizing image data.
Examples: warp(),
iradon().
Array containing down-sampling integer factor along each axis.
cval : float, optional
Constant padding value if image is not perfectly divisible by the
integer factors.
clip : bool, optional
Unused, but kept here for API consistency with the other transforms
in this module. (The local mean will never fall outside the range
of values in the input image, assuming the provided cval also
falls within that range.)
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 : _GeometricTransform or FailedEstimation
An instance of the requested transformation if the estimation
Otherwise, we return a special FailedEstimation object to signal a
failed estimation. Testing the truth value of the failed estimation
object will return False. E.g.
>>> # create transformation with explicit parameters>>> tform2=ski.transform.SimilarityTransform(scale=1.1,rotation=1,... translation=(10,20))
>>> # unite transformations, applied in order from left to right>>> tform3=tform+tform2>>> np.allclose(tform3(src),tform2(tform(src)))True
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:
>>> # A successfully estimated model is truthy (applying ``bool()``>>> # gives ``True``):>>> iftform:... print("Estimation succeeded.")Estimation succeeded.>>> # Not so for a degenerate transform with identical points.>>> bad_src=np.ones((2,2))>>> bad_tform=ski.transform
Trying to use this failed estimation transform result will give a suitable
error:
>>> bad_tform.paramsTraceback (most recent call last):...FailedEstimationAccessError: No attribute "params" for failed estimation ...
skimage.transform.frt2(a)
Compute the 2-dimensional finite Radon transform (FRT) for the input array.
Parameters:
a : ndarray of int, shape (M, M)
Input array.
Returns:
FRT : ndarray of int, shape (M+1, M)
Finite Radon Transform array of coefficients.
Notes
The FRT has a unique inverse if and only if M is prime. [FRT]
The idea for this algorithm is due to Vlad Negnevitski.
References
[FRT]
A. Kingston and I. Svalbe, “Projective transforms on periodic
discrete image arrays,” in P. Hawkes (Ed), Advances in Imaging
and Electron Physics, 139 (2006)
Examples
Generate a test image:
Use a prime number for the array dimensions
Identifies most prominent circles separated by certain distances in given
Hough spaces. Non-maximum suppression with different sizes is applied
separately in the first and second dimension of the Hough space to
identify peaks. For circles with different radius but close in distance,
only the one with highest peak is kept.
Parameters:
hspaces : (M, N, P) array
Hough spaces returned by the hough_circle function.
radii : (M,) array
Radii corresponding to Hough spaces.
min_xdistance : int, optional
Minimum distance separating centers in the x dimension.
min_ydistance : int, optional
Minimum distance separating centers in the y dimension.
threshold : float, optional
Minimum intensity of peaks in each Hough space.
Default is .
Notes
Circles with bigger radius have higher peaks in Hough space. If larger
circles are preferred over smaller ones, normalize should be False.
Otherwise, circles will be returned in the order of decreasing voting
number.
Input image with nonzero values representing edges.
threshold : int, optional
Accumulator threshold value. A lower value will return more ellipses.
accuracy : double, optional
Bin size on the minor axis used in the accumulator. A higher value
will return more ellipses, but lead to a less precise estimation of
the minor axis lengths.
min_size : int, optional
Minimal major axis length.
max_size : int, optional
Maximal minor axis length.
If None, the value is set to half of the smaller
image dimension.
Returns:
result : ndarray with fields [(accumulator, yc, xc, a, b, orientation)].
Where (yc,xc) is the center, (a,b) the major and minor
axes, respectively. The orientation value follows the
skimage.draw.ellipse_perimeter convention.
Notes
Potential ellipses in the image are characterized by their major and
minor axis lengths. For any pair of nonzero pixels in the image that
are at least half of min_size apart, an accumulator keeps track of
the minor axis lengths of potential ellipses formed with all the
other nonzero pixels. If any bin (with bin_size=accuracy*accuracy)
in the histogram of those accumulated minor axis lengths is above
threshold, the corresponding ellipse is added to the results.
A higher accuracy will therefore lead to more ellipses being found
in the image, at the cost of a less precise estimation of the minor
axis length.
References
[1]
Xie, Yonghong, and Qiang Ji. “A new efficient ellipse detection
method.” Pattern Recognition, 2002. Proceedings. 16th International
Conference on. Vol. 2. IEEE, 2002
Input image with nonzero values representing edges.
theta : ndarray of double, shape (K,), optional
Angles at which to compute the transform, in radians.
Defaults to a vector of 180 angles evenly spaced in the
range [-pi/2, pi/2).
Returns:
hspace : ndarray of uint64, shape (P, Q)
Hough transform accumulator.
angles : ndarray
Angles at which the transform is computed, in radians.
distances : ndarray
Distance values.
Notes
The origin is the top left corner of the original image.
X and Y axis are horizontal and vertical edges respectively.
The distance is the minimal algebraic distance from the origin
to the detected line.
The angle accuracy can be improved by decreasing the step size in
the theta array.
Identifies most prominent lines separated by a certain angle and distance
in a Hough transform. Non-maximum suppression with different sizes is
applied separately in the first (distances) and second (angles) dimension
of the Hough space to identify peaks.
A. Kingston and I. Svalbe, “Projective transforms on periodic
discrete image arrays,” in P. Hawkes (Ed), Advances in Imaging
and Electron Physics, 139 (2006)
Examples
>>> SIZE=59>>> img=np.tri(SIZE,dtype=np.int32)
Apply the Finite Radon Transform:
>>> f=frt2(img)
Apply the Inverse Finite Radon Transform to recover the input
The integral image contains the sum of all elements above and to the
left of it, i.e.:
S[m,n]=i≤m∑j≤n∑X[i,j]
Parameters:
image : ndarray
Input image.
dtype : data-type, optional
Data type (NumPy dtype) to be used for calculation, and for
output array S. If None, defaults to the more precise of either
float64 or image’s dtype.
Returns:
S : ndarray
Integral image/summed area table of same shape as input image.
Notes
For better accuracy and to avoid potential overflow, the data type of the
output may differ from the input’s when the default dtype of None is used.
For inputs with integer dtype, the behavior matches that for
numpy.cumsum(). Floating point inputs will be promoted to at least
double precision. The user can set dtype to override this behavior.
References
[1]
F.C. Crow, “Summed-area tables for texture mapping,”
ACM SIGGRAPH Computer Graphics, vol. 18, 1984, pp. 207-212.
Multi-Block Local Binary Pattern for texture classification
skimage.transform.integrate(ii, start, end)
Use an integral image to integrate over a given window.
Parameters:
ii : ndarray
Integral image.
start : List of tuples, each tuple of length equal to dimension of ii
Coordinates of top left corner of window(s).
Each tuple in the list contains the starting row, col, … index
i.e [(row_win1,col_win1,...),(row_win2,col_win2,...),...].
end : List of tuples, each tuple of length equal to dimension of ii
Coordinates of bottom right corner of window(s).
Each tuple in the list containing the end row, col, … index i.e
[(row_win1,col_win1,...),(row_win2,col_win2,...),...].
Returns:
S : scalar or ndarray
Integral (sum) over the given window(s).
Examples
>>> arr=np.ones((5,6),dtype=float)>>> ii=integral_image(arr)>>> integrate(ii,(1,0),(1,2))# sum from (1, 0) to (1, 2)
Reconstruct an image from the radon transform, using the filtered
back projection algorithm.
Parameters:
radon_image : ndarray
Image containing radon transform (sinogram). Each column of
the image corresponds to a projection along a different
angle. The tomography rotation axis should lie at the pixel
index radon_image.shape[0]//2 along the 0th dimension of
radon_image.
theta : array, optional
Reconstruction angles (in degrees). Default: m angles evenly spaced
between 0 and 180 (if the shape of radon_image is (N, M)).
output_size : int, optional
Number of rows and columns in the reconstruction.
filter_name : str, optional
Filter used in frequency domain filtering. Ramp filter used by default.
Filters available: ramp, shepp-logan, cosine, hamming, hann.
Assign None to use no filter.
Returns:
reconstructed : ndarray
Reconstructed image. The rotation axis will be located in the pixel
with indices
(reconstructed.shape[0]//2,reconstructed.shape[1]//2).
Notes
It applies the Fourier slice theorem to reconstruct an image by
multiplying the frequency domain of the filter with the FFT of the
projection data. This algorithm is called filtered back projection.
References
[1]
AC Kak, M Slaney, “Principles of Computerized Tomographic
Imaging”, IEEE Press 1988.
[2]
B.R. Ramesh, N. Srinivasa, K. Rajgopal, “An Algorithm for Computing
the Discrete Radon Transform With Some Applications”, Proceedings of
the Fourth IEEE Region 10 International Conference, TENCON ‘89, 1989
Reconstruct an image from the radon transform, using a single iteration of
the Simultaneous Algebraic Reconstruction Technique (SART) algorithm.
Parameters:
radon_image : ndarray, shape (M, N)
Image containing radon transform (sinogram). Each column of
the image corresponds to a projection along a different angle. The
tomography rotation axis should lie at the pixel index
radon_image.shape[0]//2 along the 0th dimension of
radon_image.
theta : array, shape (N,), optional
Reconstruction angles (in degrees). Default: m angles evenly spaced
between 0 and 180 (if the shape of radon_image is (N, M)).
image : ndarray, shape (M, M), optional
Image containing an initial reconstruction estimate. Default is an array of zeros.
projection_shifts : array, shape (N,), optional
Shift the projections contained in (the sinogram) by
this many pixels before reconstructing the image. The i’th value
defines the shift of the i’th column of .
Returns:
reconstructed : ndarray
Reconstructed image. The rotation axis will be located in the pixel
with indices
(reconstructed.shape[0]//2,reconstructed.shape[1]//2).
Notes
Algebraic Reconstruction Techniques are based on formulating the tomography
reconstruction problem as a set of linear equations. Along each ray,
the projected value is the sum of all the values of the cross section along
the ray. A typical feature of SART (and a few other variants of algebraic
techniques) is that it samples the cross section at equidistant points
along the ray, using linear interpolation between the pixel values of the
cross section. The resulting set of linear equations are then solved using
a slightly modified Kaczmarz method.
When using SART, a single iteration is usually sufficient to obtain a good
reconstruction. Further iterations will tend to enhance high-frequency
information, but will also often increase the noise.
References
[1]
AC Kak, M Slaney, “Principles of Computerized Tomographic
Imaging”, IEEE Press 1988.
[2]
AH Andersen, AC Kak, “Simultaneous algebraic reconstruction
technique (SART): a superior implementation of the ART algorithm”,
Ultrasonic Imaging 6 pp 81–94 (1984)
[3]
S Kaczmarz, “Angenäherte auflösung von systemen linearer
gleichungen”, Bulletin International de l’Academie Polonaise des
Sciences et des Lettres 35 pp 355–357 (1937)
[4]
Kohler, T. “A projection access scheme for iterative
reconstruction based on the golden section.” Nuclear Science
Symposium Conference Record, 2004 IEEE. Vol. 6. IEEE, 2004.
The returned generator yields indices into theta such that
theta[indices] gives the approximate golden ratio ordering
of the projections. In total, len(theta) indices are yielded.
All non-negative integers < len(theta) are yielded exactly once.
Notes
The method used here is that of the golden ratio introduced
by T. Kohler.
References
[1]
Kohler, T. “A projection access scheme for iterative
reconstruction based on the golden section.” Nuclear Science
Symposium Conference Record, 2004 IEEE. Vol. 6. IEEE, 2004.
[2]
Winkelmann, Stefanie, et al. “An optimal radial profile order
based on the Golden Ratio for time-resolved MRI.”
Medical Imaging, IEEE Transactions on 26.1 (2007): 68-76.
Pseudo-random number generator.
By default, a PCG64 generator is used (see numpy.random.default_rng()).
If rng is an int, it is used to seed the generator.
Returns:
lines : list
List of lines identified, lines in format ((x0, y0), (x1, y1)),
indicating line start and end.
References
[1]
C. Galamhos, J. Matas and J. Kittler, “Progressive probabilistic
Hough transform for line detection”, in IEEE Computer Society
Conference on Computer Vision and Pattern Recognition, 1999.
Sigma for Gaussian filter. Default is 2*upscale/6.0 which
corresponds to a filter mask twice the size of the scale factor that
covers more than 99% of the Gaussian distribution.
order : int, optional
Order of splines used in interpolation of upsampling. See
skimage.transform.warp for detail.
Yield images of the Gaussian pyramid formed by the input image.
Recursively applies the pyramid_reduce function to the image, and yields
the downscaled images.
Note that the first image of the pyramid will be the original, unscaled
image. The total number of images is max_layer+1. In case all layers
are computed, the last image is either a one-pixel image or the image where
the reduction does not change its shape.
Parameters:
image : ndarray
Input image.
max_layer : int, optional
Number of layers for the pyramid. 0th layer is the original image.
Default is -1 which builds all possible layers.
Note that the first image of the pyramid will be the difference between the
original, unscaled image and its smoothed version. The total number of
images is max_layer+1. In case all layers are computed, the last image
is either a one-pixel image or the image where the reduction does not
change its shape.
Sigma for Gaussian filter. Default is 2*downscale/6.0 which
corresponds to a filter mask twice the size of the scale factor that
covers more than 99% of the Gaussian distribution.
order : int, optional
Order of splines used in interpolation of downsampling. See
skimage.transform.warp for detail.
Calculates the radon transform of an image given specified
projection angles.
Parameters:
image : ndarray
Input image. The rotation axis will be located in the pixel with
indices (image.shape[0]//2,image.shape[1]//2).
theta : array, optional
Projection angles (in degrees). If None, the value is set to
np.arange(180).
circle : bool, optional
Assume image is zero outside the inscribed circle, making the
width of each projection (the first dimension of the sinogram)
equal to min(image.shape).
AC Kak, M Slaney, “Principles of Computerized Tomographic
Imaging”, IEEE Press 1988.
[2]
B.R. Ramesh, N. Srinivasa, K. Rajgopal, “An Algorithm for Computing
the Discrete Radon Transform With Some Applications”, Proceedings of
the Fourth IEEE Region 10 International Conference, TENCON ‘89, 1989
Performs interpolation to up-scale or down-scale N-dimensional images.
Note that anti-aliasing should be enabled when down-sizing images to avoid
aliasing artifacts. For down-sampling with an integer factor also see
skimage.transform.downscale_local_mean.
Parameters:
image : (M, N[, …][, C]) ndarray
Input image.
scale : {float, tuple of floats}
Scale factors for spatial dimensions. Separate scale factors can be defined as
(m, n[, …]).
Performs interpolation to up-size or down-size N-dimensional images. Note
that anti-aliasing should be enabled when down-sizing images to avoid
aliasing artifacts. For downsampling with an integer factor also see
skimage.transform.downscale_local_mean.
Parameters:
image : ndarray
Input image.
output_shape : iterable
Size of the generated output image (rows,cols[,...][,dim]). If
dim is not provided, the number of channels is preserved. In case the
number of input channels does not equal the number of output channels a
n-dimensional interpolation is applied.
Returns:
resized : ndarray
Resized version of the input. See Notes regarding dtype.
Other Parameters
Notes
Modes ‘reflect’ and ‘symmetric’ are similar, but differ in whether the edge
pixels are duplicated during the reflection. As an example, if an array
has values [0, 1, 2] and was padded to the right by four values using
symmetric, the result would be [0, 1, 2, 2, 1, 0, 0], while for reflect it
would be [0, 1, 2, 1, 0, 1, 2].
resize uses interpolation. Unless the interpolation method is nearest-neighbor
(order==0), the algorithm will generate output values as weighted averages
of input values. Accordingly, the output dtype is float64 with the following
exceptions:
When order==0, the output dtype is image.dtype.
When image.dtype is float16 or float32, the output dtype is
float32.
For a similar function that preserves the dtype of the input, consider
scipy.ndimage.zoom.
Resize an array with the local mean / bilinear scaling.
Parameters:
image : ndarray
Input image. If this is a multichannel image, the axis corresponding
to channels should be specified using channel_axis.
output_shape : iterable
Size of the generated output image. When channel_axis is not None,
the channel_axis should either be omitted from output_shape or the
output_shape[channel_axis] must match
image.shape[channel_axis]. If the length of output_shape exceeds
image.ndim, additional singleton dimensions will be appended to the
input image as needed.
grid_mode : bool, optional
Defines image pixels position: if True, pixels are assumed to be at
grid intersections, otherwise at cell centers. As a consequence,
for example, a 1d signal of length 5 is considered to have length 4
when grid_mode is False, but length 5 when grid_mode is True. See
the following visual illustration:
This method is sometimes referred to as “area-based” interpolation or
“pixel mixing” interpolation [1]. When grid_mode is True, it is
equivalent to using OpenCV’s resize with INTER_AREA interpolation mode.
It is commonly used for image downsizing. If the downsizing factors are
integers, then downscale_local_mean should be preferred instead.
Rotate image by a certain angle around its center.
Parameters:
image : ndarray
Input image.
angle : float
Rotation angle in degrees in counter-clockwise direction.
resize : bool, optional
Determine whether the shape of the output image will be automatically
calculated, so the complete rotated image exactly fits. Default is
False.
center : iterable of length 2
The rotation center. If center=None, the image is rotated around
its center, i.e. center=(cols/2-0.5,rows/2-0.5). Please
note that this parameter is (cols, rows), contrary to normal skimage
ordering.
Returns:
rotated : ndarray
Rotated version of the input.
Other Parameters:
order : int, optional
The order of the spline interpolation, default is 0 if
image.dtype is bool and 1 otherwise. The order has to be in
the range 0-5. See skimage.transform.warp for detail.
Points outside the boundaries of the input are filled according
to the given mode. Modes match the behaviour of numpy.pad.
cval : float, optional
Used in conjunction with mode ‘constant’, the value outside
the image boundaries.
clip : bool, optional
Whether to clip the output to the range of values of the input image.
This is enabled by default, since higher order interpolation may
produce values outside the given input range.
Notes
Modes ‘reflect’ and ‘symmetric’ are similar, but differ in whether the edge
pixels are duplicated during the reflection. As an example, if an array
has values [0, 1, 2] and was padded to the right by four values using
symmetric, the result would be [0, 1, 2, 2, 1, 0, 0], while for reflect it
would be [0, 1, 2, 1, 0, 1, 2].
Warp an image according to a given coordinate transformation.
Parameters:
image : ndarray
Input image.
inverse_map : transformation object, callable cr=f(cr,**kwargs), or ndarray
Inverse coordinate map, which transforms coordinates in the output
images into their corresponding coordinates in the input image.
There are a number of different options to define this map, depending
on the dimensionality of the input image. A 2-D image can have 2
dimensions for gray-scale images, or 3 dimensions with color
information.
You can also use the inverse of a geometric transformation (fast):
>>> warped=warp(image,tform.inverse)
For N-D images you can pass a coordinate array, that specifies the
coordinates in the input image for every element in the output image. E.g.
if you want to rescale a 3-D cube, you can do:
Assume that the cube contains spatial data, where the first array element
center is at coordinate (0.5, 0.5, 0.5) in real space, i.e. we have to
account for this extra offset when scaling the image:
Build the source coordinates for the output of a 2-D image warp.
Parameters:
coord_map : callable like GeometricTransform.inverse
Return input coordinates for given output coordinates.
Coordinates are in the shape (P, 2), where P is the number
of coordinates and each element is a (row,col) pair.
shape : tuple
Shape of output image (rows,cols[,bands]).
dtype : np.dtype or string
dtype for return value (sane choices: float32 or float64).
Returns:
coords : (ndim, rows, cols[, bands]) array of dtype dtype
Coordinates for scipy.ndimage.map_coordinates, that will yield
an image of shape (orows, ocols, bands) by drawing from source
points according to the coord_transform_fn.
Notes
This is a lower-level routine that produces the source coordinates for 2-D
images used by warp().
It is provided separately from warp to give additional flexibility to
users who would like, for example, to re-use a particular coordinate
mapping, to use specific dtypes at various points along the the
image-warping process, or to implement different post-processing logic
than warp performs after the call to ndi.map_coordinates.
Examples
Produce a coordinate map that shifts an image up and to the right:
Remap image to polar or log-polar coordinates space.
Parameters:
image : (M, N[, C]) ndarray
Input image. For multichannel images channel_axis has to be specified.
center : 2-tuple, optional
(row,col) coordinates of the point in image that represents the center of
the transformation (i.e., the origin in Cartesian space). Values can be of
type float. If no value is given, the center is assumed to be the center point
of image.
radius : float, optional
Radius of the circle that bounds the area to be transformed.
output_shape : tuple (row, col), optional
scaling : {‘linear’, ‘log’}, optional
Specify whether the image warp is polar or log-polar. Defaults to
‘linear’.
channel_axis : int or None, optional
If None, the image is assumed to be a grayscale (single channel) image.
Otherwise, this parameter indicates which axis of the array corresponds
to channels.
where sx and sy are scale factors in the x and y directions.
This is equivalent to applying the operations in the following order:
Scale
Shear
Rotate
Translate
The homogeneous transformation matrix is:
[[a0a1a2][b0b1b2][001]]
In 2D, the transformation parameters can be given as the homogeneous
transformation matrix, above, or as the implicit parameters, scale,
rotation, shear, and translation in x (a2) and y (b2). For 3D and higher,
only the matrix form is allowed.
In narrower transforms, such as the Euclidean (only rotation and
translation) or Similarity (rotation, translation, and a global scale
factor) transforms, it is possible to specify 3D transforms using implicit
parameters also.
Parameters:
matrix : (D+1, D+1) array_like, optional
Homogeneous transformation matrix. If this matrix is provided, it is an
error to provide any of scale, rotation, shear, or translation.
scale : {s as float or (sx, sy) as array, list or tuple}, optional
Scale factor(s). If a single value, it will be assigned to both
sx and sy. Only available for 2D.
shear : float or 2-tuple of float, optional
The x and y shear angles, clockwise, by which these axes are
rotated around the origin [2].
If a single value is given, take that to be the x shear angle, with
the y angle remaining 0. Only available in 2D.
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:
>>> # A successfully estimated model is truthy (applying ``bool()``>>> # gives ``True``):>>> iftform:... print("Estimation succeeded.")Estimation succeeded.>>> # Not so for a degenerate transform with identical points.>>> bad_src=np.ones((3,2))>>> bad_tform=ski.transform
Trying to use this failed estimation transform result will give a suitable
error:
>>> bad_tform.paramsTraceback (most recent call last):...FailedEstimationAccessError: No attribute "params" for failed estimation ...
Deprecated:estimate is deprecated since version 0.26 and will be removed in version 2.2. Please use AffineTransform.from_estimate class constructor instead.
Estimate the transformation from a set of corresponding points.
You can determine the over-, well- and under-determined parameters
with the total least-squares method.
Number of source and destination coordinates must match.
The transformation is defined as:
classmethodfrom_estimate(dst, weights=None)
Estimate the transformation from a set of corresponding points.
You can determine the over-, well- and under-determined parameters
with the total least-squares method.
Number of source and destination coordinates must match.
The transformation is defined as:
X=(a0*x+a1*y+a2
classmethodidentity(dimensionality=None)
Identity transform
Parameters:
dimensionality : {None, int}, optional
Dimensionality of identity transform.
Returns:
tform : transform
Transform such that .
propertyinverse
Return a transform object representing the inverse.
residuals(src, dst)
Determine residuals of transformed destination coordinates.
For each transformed source coordinate the Euclidean distance to the
respective destination coordinate is determined.
The essential matrix relates corresponding points between a pair of
calibrated images. The matrix transforms normalized, homogeneous image
points in one image to epipolar lines in the other image.
The essential matrix is only defined for a pair of moving images capturing a
non-planar scene. In the case of pure rotation or planar scenes, the
homography describes the geometric relation between two images
(ProjectiveTransform). If the intrinsic calibration of the images is
unknown, the fundamental matrix describes the projective relation between
the two images (FundamentalMatrixTransform).
Parameters:
rotation : (3, 3) array_like, optional
Rotation matrix of the relative camera motion.
translation : (3, 1) array_like, optional
Translation vector of the relative camera motion. The vector must
have unit length.
matrix : (3, 3) array_like, optional
Essential matrix.
dimensionality : int, optional
Fallback number of dimensions when matrix not specified, in which
case, must equal 2 (the default).
Attributes:
params(3, 3) array
References
[1]
Hartley, Richard, and Andrew Zisserman. Multiple view geometry in
computer vision. Cambridge university press, 2003.
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:
>>> # A successfully estimated model is truthy (applying ``bool()``>>> # gives ``True``):>>> iftform:... print("Estimation succeeded.")Estimation succeeded.>>> # Not so for a degenerate transform with identical points.>>> bad_src=np.ones((8,2))>>> bad_tform=ski.transform
Trying to use this failed estimation transform result will give a suitable
error:
>>> bad_tform.paramsTraceback (most recent call last):...FailedEstimationAccessError: No attribute "params" for failed estimation ...
Estimate essential matrix using 8-point algorithm.
The 8-point algorithm requires at least 8 corresponding point pairs for
a well-conditioned solution, otherwise the over-determined solution is
estimated.
Parameters:
classmethodfrom_estimate(src, dst)
Estimate essential matrix using 8-point algorithm.
The 8-point algorithm requires at least 8 corresponding point pairs for
a well-conditioned solution, otherwise the over-determined solution is
estimated.
Parameters:
src : (N, 2) array_like
Source coordinates.
dst : (N, 2) array_like
Destination coordinates.
Returns:
classmethodidentity(dimensionality=None)
Identity transform
Parameters:
dimensionality : {None, 2}, optional
This transform only allows dimensionality of 2, where None
corresponds to 2. The parameter exists for compatibility with other
transforms.
Returns:
tform : transform
Transform such that .
propertyinverse
Return a transform object representing the inverse.
See Hartley & Zisserman, Ch. 8: Epipolar Geometry and the Fundamental
Matrix, for an explanation of why F.T gives the inverse.
residuals(src, dst)
Compute the Sampson distance.
The Sampson distance is the first approximation to the geometric error.
The Euclidean transformation is a rigid transformation with rotation and
translation parameters. The similarity transformation extends the Euclidean
transformation with a single scaling factor.
In 2D and 3D, the transformation parameters may be provided either via
matrix, the homogeneous transformation matrix, above, or via the
implicit parameters rotation and/or translation (where a1 is the
translation along x, b1 along y, etc.). Beyond 3D, if the
transformation is only a translation, you may use the implicit parameter
translation; otherwise, you must use matrix.
The implicit parameters are applied in the following order:
Rotation;
Translation.
Parameters:
matrix : (D+1, D+1) array_like, optional
Homogeneous transformation matrix.
rotation : float or sequence of float, optional
Rotation angle, clockwise, in radians. If given as a vector, it is
interpreted as Euler rotation angles [1]. Only 2D (single rotation)
and 3D (Euler rotations) values are supported. For higher dimensions,
you must provide or estimate the transformation matrix instead, and
pass that as matrix above.
Fallback number of dimensions for transform when no other parameter
is specified. Otherwise ignored, and we infer dimensionality from the
input parameters.
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:
>>> # A successfully estimated model is truthy (applying ``bool()``>>> # gives ``True``):>>> iftform:... print("Estimation succeeded.")Estimation succeeded.>>> # Not so for a degenerate transform with identical points.>>> bad_src=np.ones((3,2))>>> bad_tform=ski.transform
Trying to use this failed estimation transform result will give a suitable
error:
>>> bad_tform.paramsTraceback (most recent call last):...FailedEstimationAccessError: No attribute "params" for failed estimation ...
The fundamental matrix relates corresponding points between a pair of
uncalibrated images. The matrix transforms homogeneous image points in one
image to epipolar lines in the other image.
The fundamental matrix is only defined for a pair of moving images. In the
case of pure rotation or planar scenes, the homography describes the
geometric relation between two images (ProjectiveTransform). If the
intrinsic calibration of the images is known, the essential matrix describes
the metric relation between the two images (EssentialMatrixTransform).
Parameters:
matrix : (3, 3) array_like, optional
Fundamental matrix.
dimensionality : int, optional
Fallback number of dimensions when matrix not specified, in which
case, must equal 2 (the default).
Attributes:
params : (3, 3) array
Fundamental matrix.
Notes
See [1] and [2] for details of the estimation procedure. [2] is a good
place to start.
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:
>>> # A successfully estimated model is truthy (applying ``bool()``>>> # gives ``True``):>>> iftform:... print("Estimation succeeded.")Estimation succeeded.>>> # Not so for a degenerate transform with identical points.>>> bad_src=np.ones((8,2))>>> bad_tform=ski.transform
Trying to use this failed estimation transform result will give a suitable
error:
>>> bad_tform.paramsTraceback (most recent call last):...FailedEstimationAccessError: No attribute "params" for failed estimation ...
Estimate fundamental matrix using 8-point algorithm.
The 8-point algorithm requires at least 8 corresponding point pairs for
a well-conditioned solution, otherwise the over-determined solution is
estimated.
Parameters:
classmethodfrom_estimate(src, dst)
Estimate fundamental matrix using 8-point algorithm.
The 8-point algorithm requires at least 8 corresponding point pairs.
Parameters:
src : (N, 2) array_like
Source coordinates.
dst : (N, 2) array_like
Destination coordinates.
Returns:
classmethodidentity(dimensionality=None)
Identity transform
Parameters:
dimensionality : {None, 2}, optional
This transform only allows dimensionality of 2, where None
corresponds to 2. The parameter exists for compatibility with other
transforms.
Returns:
tform : transform
Transform such that .
propertyinverse
Return a transform object representing the inverse.
See Hartley & Zisserman, Ch. 8: Epipolar Geometry and the Fundamental
Matrix, for an explanation of why F.T gives the inverse.
residuals(src, dst)
Compute the Sampson distance.
The Sampson distance is the first approximation to the geometric error.
Parameters:
src : (N, 2) array
Source coordinates.
dst : (N, 2) array
Destination coordinates.
Returns:
residuals : (N,) array
scaling='rms'
classskimage.transform.PiecewiseAffineTransform
Bases: _GeometricTransform
Piecewise affine transformation.
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.
Calling the transform applies the transformation to the points:
>>> np.allclose(tform(src),dst)True
You can apply the inverse transform:
>>> np.allclose(tform.inverse(dst),src)True
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:
>>> # A successfully estimated model is truthy (applying ``bool()``>>> # gives ``True``):>>> iftform:... print("Estimation succeeded.")Estimation succeeded.>>> # Not so for a degenerate transform with identical points.>>> bad_src=[[1,1]]*6+src[6:]>>>
Trying to use this failed estimation transform result will give a suitable
error:
>>> bad_tform.paramsTraceback (most recent call last):...FailedEstimationAccessError: No attribute "params" for failed estimation ...
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:
>>> # A successfully estimated model is truthy (applying ``bool()``>>> # gives ``True``):>>> iftform:... print("Estimation succeeded.")Estimation succeeded.>>> # Not so for a degenerate transform with identical points.>>> bad_src=np.ones((3,2))>>> bad_tform=ski.transform
Trying to use this failed estimation transform result will give a suitable
error:
>>> bad_tform.paramsTraceback (most recent call last):...FailedEstimationAccessError: No attribute "params" for failed estimation ...
where s is a scale factor and the homogeneous transformation matrix is:
[[a0-b0a1][b0a0b1][001]]
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 : (dim+1, dim+1) array_like, optional
Homogeneous transformation matrix.
scale : float, optional
Scale factor. Implemented only for 2D and 3D.
rotation : float, optional
Rotation angle, clockwise, as radians.
Implemented only for 2D and 3D. For 3D, this is given in ZYX Euler
angles.
translation : (dim,) array_like, optional
x, y[, z] translation parameters. Implemented only for 2D and 3D.
dimensionality : int, optional
The dimensionality of the transform, corresponding to dim above.
Ignored if is not None, and set to .
Otherwise, must be one of 2 or 3.
Examples
>>> importnumpyasnp>>> importskimageasski
Define a transform with an homogeneous transformation matrix:
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:
>>> # A successfully estimated model is truthy (applying ``bool()``>>> # gives ``True``):>>> iftform:... print("Estimation succeeded.")Estimation succeeded.>>> # Not so for a degenerate transform with identical points.>>> bad_src=np.ones((3,2))>>> bad_tform=ski.transform
Trying to use this failed estimation transform result will give a suitable
error:
>>> bad_tform.paramsTraceback (most recent call last):...FailedEstimationAccessError: No attribute "params" for failed estimation ...
Given two matching sets of points, source and destination, this class
estimates the thin-plate spline (TPS) transformation which transforms
each point in source into its destination counterpart.
Attributes:
src : (N, 2) array_like
Coordinates of control points in source image.
References
[1]
Bookstein, Fred L. “Principal warps: Thin-plate splines and the
decomposition of deformations,” IEEE Transactions on pattern analysis
and machine intelligence 11.6 (1989): 567–585.
DOI:10.1109/34.24792https://user.engineering.uiowa.edu/~aip/papers/bookstein-89.pdf
Examples
>>> importskimageasski
Define source and destination control points such that they simulate
rotating by 90 degrees and generate a meshgrid from them:
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:
Estimate optimal spline mappings between source and destination points.
Parameters:
src : (N, 2) array_like
Control points at source coordinates.
dst : (N, 2) array_like
propertyinverse
: ndarray
Down-sampled image with same number of dimensions as input image.
For integer inputs, the output dtype will be float64.
See numpy.mean() for details.
(
f
"Failed estimation:
{
tf
}
"
)
,
-
20
])
.
reshape
((
2
,
2
))
.
estimate_transform
(
'similarity'
,
...
bad_src
,
dst
)
>>>
if
not
bad_tform
:
...
print
(
"Estimation failed."
)
Estimation failed.
35
,
23
)
>>>
img
[
rr
,
cc
]
=
1
>>>
try_radii
=
np
.
arange
(
5
,
50
)
>>>
res
=
hough_circle
(
img
,
try_radii
)
>>>
ridx
,
r
,
c
=
np
.
unravel_index
(
np
.
argmax
(
res
),
res
.
shape
)
>>>
r
,
c
,
try_radii
[
ridx
]
(25, 35, 23)
0.5
*
max(hspace)
num_peaks : int, optional
Maximum number of peaks in each Hough space. When the
number of peaks exceeds num_peaks, only num_peaks
coordinates based on peak intensity are considered for the
corresponding radius.
total_num_peaks : int, optional
Maximum number of peaks. When the number of peaks exceeds num_peaks,
return num_peaks coordinates based on peak intensity.
normalize : bool, optional
If True, normalize the accumulator by the radius to sort the prominent
peaks.
Returns:
accum, cx, cy, rad : tuple of array
Peak values in Hough space, x and y center coordinates and radii.
)
>>>
y
,
x
=
draw
.
circle_perimeter
(
y_0
,
x_0
,
radius
)
>>>
img
[
x
,
y
]
=
1
>>>
hspaces
=
transform
.
hough_circle
(
img
,
radius
)
>>>
accum
,
cx
,
cy
,
rad
=
hough_circle_peaks
(
hspaces
,
[
radius
,])
(
10
,
10
,
6
,
8
)
>>>
img
[
cc
,
rr
]
=
1
>>>
result
=
hough_ellipse
(
img
,
threshold
=
8
)
>>>
result
.
tolist
()
[(10, 10.0, 10.0, 8.0, 6.0, 0.0)]
35
:
50
]
=
1
>>>
for
i
in
range
(
90
):
...
img
[
i
,
i
]
=
1
>>>
rng
=
np
.
random
.
default_rng
()
>>>
img
+=
rng
.
random
(
img
.
shape
)
>
0.95
0
,
0
,
14
,
14
)
>>>
img
[
rr
,
cc
]
=
1
>>>
rr
,
cc
=
line
(
0
,
14
,
14
,
0
)
>>>
img
[
cc
,
rr
]
=
1
>>>
hspace
,
angles
,
dists
=
hough_line
(
img
)
>>>
hspace
,
angles
,
dists
=
hough_line_peaks
(
hspace
,
angles
,
dists
)
>>>
len
(
angles
)
2
array([3.])
>>>
integrate
(
ii
,
[(
3
,
3
)],
[(
4
,
5
)])
# sum from (3, 3) to (4, 5)
array([6.])
>>>
# sum from (1, 0) to (1, 2) and from (3, 3) to (4, 5)
>>>
integrate
(
ii
,
[(
1
,
0
),
(
3
,
3
)],
[(
1
,
2
),
(
4
,
5
)])
array([3., 6.])
interpolation
: str, optional
Interpolation method used in reconstruction. Methods available:
‘linear’, ‘nearest’, and ‘cubic’ (‘cubic’ is slow).
circle : bool, optional
Assume the reconstructed image is zero outside the inscribed circle.
Also changes the default output_size to match the behaviour of
radon called with circle=True.
Force all values in the reconstructed tomogram to lie in the range
[clip[0],clip[1]]
relaxation : float, optional
Relaxation parameter for the update step. A higher value can
improve the convergence rate, but one runs the risk of instabilities.
Values close to or higher than 1 are not recommended.
dtype : dtype, optional
Output data type, must be floating point. By default, if input
data type is not float, input is cast to double, otherwise
dtype is set to input data type.
The mode parameter determines how the array borders are handled, where
cval is the value when mode is equal to ‘constant’.
cval : float, optional
Value to fill past edges of input if mode is ‘constant’.
If None, the image is assumed to be a grayscale (single channel) image.
Otherwise, this parameter indicates which axis of the array corresponds
to channels.
sigma
: float, optional
Sigma for Gaussian filter. Default is 2*downscale/6.0 which
corresponds to a filter mask twice the size of the scale factor that
covers more than 99% of the Gaussian distribution.
order : int, optional
Order of splines used in interpolation of downsampling. See
skimage.transform.warp for detail.
If None, the image is assumed to be a grayscale (single channel) image.
Otherwise, this parameter indicates which axis of the array corresponds
to channels.
Returns:
pyramid : generator
Generator yielding pyramid layers as float images.
Number of layers for the pyramid. 0th layer is the original image.
Default is -1 which builds all possible layers.
downscale : float, optional
Downscale factor.
sigma : float, optional
Sigma for Gaussian filter. Default is 2*downscale/6.0 which
corresponds to a filter mask twice the size of the scale factor that
covers more than 99% of the Gaussian distribution.
order : int, optional
Order of splines used in interpolation of downsampling. See
skimage.transform.warp for detail.
If None, the image is assumed to be a grayscale (single channel) image.
Otherwise, this parameter indicates which axis of the array corresponds
to channels.
Returns:
pyramid : generator
Generator yielding pyramid layers as float images.
If None, the image is assumed to be a grayscale (single channel) image.
Otherwise, this parameter indicates which axis of the array corresponds
to channels.
:
order : int, optional
The order of the spline interpolation, default is 0 if
image.dtype is bool and 1 otherwise. The order has to be in
the range 0-5. See skimage.transform.warp for detail.
Points outside the boundaries of the input are filled according
to the given mode. Modes match the behaviour of numpy.pad.
cval : float, optional
Used in conjunction with mode ‘constant’, the value outside
the image boundaries.
clip : bool, optional
Whether to clip the output to the range of values of the input image.
This is enabled by default, since higher order interpolation may
produce values outside the given input range.
Whether to apply a Gaussian filter to smooth the image prior
to down-scaling. It is crucial to filter when down-sampling
the image to avoid aliasing artifacts. If input image data
type is bool, no anti-aliasing is applied.
anti_aliasing_sigma : {float, tuple of floats}, optional
Standard deviation for Gaussian filtering to avoid aliasing artifacts.
By default, this value is chosen as (s - 1) / 2 where s is the
down-scaling factor.
channel_axis : int or None, optional
If None, the image is assumed to be a grayscale (single channel) image.
Otherwise, this parameter indicates which axis of the array corresponds
to channels.
Notes
Modes ‘reflect’ and ‘symmetric’ are similar, but differ in whether the edge
pixels are duplicated during the reflection. As an example, if an array
has values [0, 1, 2] and was padded to the right by four values using
symmetric, the result would be [0, 1, 2, 2, 1, 0, 0], while for reflect it
would be [0, 1, 2, 1, 0, 1, 2].
The order of the spline interpolation, default is 0 if
image.dtype is bool and 1 otherwise. The order has to be in
the range 0-5. See skimage.transform.warp for detail.
Points outside the boundaries of the input are filled according
to the given mode. Modes match the behaviour of numpy.pad.
cval : float, optional
Used in conjunction with mode ‘constant’, the value outside
the image boundaries.
clip : bool, optional
Whether to clip the output to the range of values of the input image.
This is enabled by default, since higher order interpolation may
produce values outside the given input range.
Whether to apply a Gaussian filter to smooth the image prior
to downsampling. It is crucial to filter when downsampling
the image to avoid aliasing artifacts. If not specified, it is set to
True when downsampling an image whose data type is not bool.
It is also set to False when using nearest neighbor interpolation
(order == 0) with integer input data type.
anti_aliasing_sigma : {float, tuple of floats}, optional
Standard deviation for Gaussian filtering used when anti-aliasing.
By default, this value is chosen as (s - 1) / 2 where s is the
downsampling factor, where s > 1. For the up-size case, s < 1, no
anti-aliasing is performed prior to rescaling.
Shape of the output image generated. By default the shape of the input
image is preserved.
order : int, optional
The order of the spline interpolation, default is 0 if
image.dtype is bool and 1 otherwise. The order has to be in
the range 0-5. See skimage.transform.warp for detail.
Points outside the boundaries of the input are filled according
to the given mode, with ‘reflect’ used as the default. Modes match
the behaviour of numpy.pad.
cval : float, optional
Used in conjunction with mode ‘constant’, the value outside
the image boundaries.
clip : bool, optional
Whether to clip the output to the range of values of the input image.
This is enabled by default, since higher order interpolation may
produce values outside the given input range.
For 2-D images, a function that transforms a (M,2) array of
(col,row) coordinates in the output image to their
corresponding coordinates in the input image. Extra parameters to
the function can be specified through map_args.
For N-D images, you can directly pass an array of coordinates.
The first dimension specifies the coordinates in the input image,
while the subsequent dimensions determine the position in the
output image. E.g. in case of 2-D images, you need to pass an array
of shape (2,rows,cols), where rows and cols determine the
shape of the output image, and the first dimension contains the
(row,col) coordinate in the input image.
See scipy.ndimage.map_coordinates for further documentation.
Note, that a (3,3) matrix is interpreted as a homogeneous
transformation matrix, so you cannot interpolate values from a 3-D
input, if the output is of shape (3,).
See example section for usage.
map_args : dict, optional
Keyword arguments passed to inverse_map.
output_shape : tuple (rows, cols), optional
Shape of the output image generated. By default the shape of the input
image is preserved. Note that, even for multi-band images, only rows
and columns need to be specified.
order : int, optional
The order of interpolation. The order has to be in the range 0-5:
0: Nearest-neighbor
1: Bi-linear (default)
2: Bi-quadratic
3: Bi-cubic
4: Bi-quartic
5: Bi-quintic
Default is 0 if image.dtype is bool and 1 otherwise.
Points outside the boundaries of the input are filled according
to the given mode. Modes match the behaviour of numpy.pad.
cval : float, optional
Used in conjunction with mode ‘constant’, the value outside
the image boundaries.
clip : bool, optional
Whether to clip the output to the range of values of the input image.
This is enabled by default, since higher order interpolation may
produce values outside the given input range.
which exist for each set of corresponding points, so we have a set of
N * 2 equations. The coefficients appear linearly so we can write
A x = 0, where:
In case of total least-squares the solution of this homogeneous system
of equations is the right singular vector of A which corresponds to the
smallest singular value normed by the coefficient c3.
Weights can be applied to each pair of corresponding points to
indicate, particularly in an overdetermined system, if point pairs have
higher or lower confidence or uncertainties associated with them. From
the matrix treatment of least squares problems, these weight values are
normalized, square-rooted, then built into a diagonal matrix, by which
A is multiplied.
In case of the affine transformation the coefficients c0 and c1 are 0.
Thus the system of equations is:
which exist for each set of corresponding points, so we have a set of
N * 2 equations. The coefficients appear linearly so we can write
A x = 0, where:
In case of total least-squares the solution of this homogeneous system
of equations is the right singular vector of A which corresponds to the
smallest singular value normed by the coefficient c3.
Weights can be applied to each pair of corresponding points to
indicate, particularly in an overdetermined system, if point pairs have
higher or lower confidence or uncertainties associated with them. From
the matrix treatment of least squares problems, these weight values are
normalized, square-rooted, then built into a diagonal matrix, by which
A is multiplied.
In case of the affine transformation the coefficients c0 and c1 are 0.
Thus the system of equations is:
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.
True, if all pieces of the model are successfully estimated.
tf
: Self or FailedEstimation
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.
which exist for each set of corresponding points, so we have a set of
N * 2 equations. The coefficients appear linearly so we can write
A x = 0, where:
In case of total least-squares the solution of this homogeneous system
of equations is the right singular vector of A which corresponds to the
smallest singular value normed by the coefficient c3.
Weights can be applied to each pair of corresponding points to
indicate, particularly in an overdetermined system, if point pairs have
higher or lower confidence or uncertainties associated with them. From
the matrix treatment of least squares problems, these weight values are
normalized, square-rooted, then built into a diagonal matrix, by which
A is multiplied.
Parameters:
src : (N, 2) array_like
Source coordinates.
dst : (N, 2) array_like
Destination coordinates.
order : int, optional
Polynomial order (number of coefficients is order + 1).
weights : (N,) array_like, optional
Relative weight values for each pair of points.
Returns:
success : bool
True, if model estimation succeeds.
:
order
](
sum
[
i
=
0
:
j
](
a_ji
*
x
**
(
j
-
i
)
*
y
**
i
))
Y
=
sum
[
j
=
0
:
order
](
sum
[
i
=
0
:
j
](
b_ji
*
x
**
(
j
-
i
)
*
y
**
i
))
These equations can be transformed to the following form:
which exist for each set of corresponding points, so we have a set of
N * 2 equations. The coefficients appear linearly so we can write
A x = 0, where:
In case of total least-squares the solution of this homogeneous system
of equations is the right singular vector of A which corresponds to the
smallest singular value normed by the coefficient c3.
Weights can be applied to each pair of corresponding points to
indicate, particularly in an overdetermined system, if point pairs have
higher or lower confidence or uncertainties associated with them. From
the matrix treatment of least squares problems, these weight values are
normalized, square-rooted, then built into a diagonal matrix, by which
A is multiplied.
Parameters:
src : (N, 2) array_like
Source coordinates.
dst : (N, 2) array_like
Destination coordinates.
order : int, optional
Polynomial order (number of coefficients is order + 1).
weights : (N,) array_like, optional
Relative weight values for each pair of points.
Returns:
tf : Self or FailedEstimation
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.
which exist for each set of corresponding points, so we have a set of
N * 2 equations. The coefficients appear linearly so we can write
A x = 0, where:
In case of total least-squares the solution of this homogeneous system
of equations is the right singular vector of A which corresponds to the
smallest singular value normed by the coefficient c3.
Weights can be applied to each pair of corresponding points to
indicate, particularly in an overdetermined system, if point pairs have
higher or lower confidence or uncertainties associated with them. From
the matrix treatment of least squares problems, these weight values are
normalized, square-rooted, then built into a diagonal matrix, by which
A is multiplied.
In case of the affine transformation the coefficients c0 and c1 are 0.
Thus the system of equations is:
which exist for each set of corresponding points, so we have a set of
N * 2 equations. The coefficients appear linearly so we can write
A x = 0, where:
In case of total least-squares the solution of this homogeneous system
of equations is the right singular vector of A which corresponds to the
smallest singular value normed by the coefficient c3.
Weights can be applied to each pair of corresponding points to
indicate, particularly in an overdetermined system, if point pairs have
higher or lower confidence or uncertainties associated with them. From
the matrix treatment of least squares problems, these weight values are
normalized, square-rooted, then built into a diagonal matrix, by which
A is multiplied.
In case of the affine transformation the coefficients c0 and c1 are 0.
Thus the system of equations is:
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.
True indicates that the estimation was successful.
Notes
The number N of source and destination points must match.
Control points at destination coordinates.
Returns:
tform : Self or FailedEstimation
An instance of the transformation if the estimation succeeded.
Otherwise, we return a special FailedEstimation object to
signal a failed estimation. Testing the truth value of the failed
estimation object will return False. E.g.