Expand description
Geometric transforms with B-spline interpolation, following scipy.ndimage: spline_filter,
map_coordinates, affine_transform, shift, zoom and rotate.
Every geometric transform has the same core: for each output pixel, compute where it comes from
in the input (generally between pixels) and interpolate there. Interpolation of order k fits a
piecewise polynomial of degree k that is k − 1 times differentiable: order 0 takes the
nearest pixel, order 1 is bilinear, and order 3 (the default) is the cubic B-spline. For orders
above 1 the spline must pass through the pixels, which requires solving for its coefficients
first: the prefilter, a pair of recursive filters per pole, run along each axis.
See the book entry Rank filters, derivative filters and geometric transforms.
Functions§
- affine_
transform - The affine transform (SciPy’s
affine_transform): output pixelotakes the input value atmatrix · o + offset, interpolated. Note the direction: the matrix maps output coordinates to input coordinates, so to rotate an image byθthe matrix is the rotation by−θ. - map_
coordinates - Interpolates
imageat arbitrary points(row, column)(SciPy’smap_coordinates), with spline order 0 to 5. Coefficients fromspline_filterare combined with B-spline weights over the(k + 1) × (k + 1)neighbourhood of each point. InConstantmode, points outside the image (beyond−0.5 … n − 0.5… precisely, outside[0, n − 1]) take the constant, as in SciPy. - rotate
- Rotates the image by
angledegrees about its centre (SciPy’srotate, axes(1, 0)): a positive angle turns the content anticlockwise on the screen. Withreshapethe output grows to hold the whole rotated image. - shift
- Shifts the image by
(rows, columns)pixels: outputotakes inputo − shift. - spline_
filter - B-spline coefficients of
imagefor interpolation of the given order (SciPy’sspline_filterwith the boundary condition thatmodeimplies). Returns the coefficients and the padding added at each side. - zoom
- Resizes the image by factors
(rows, columns)(SciPy’szoomwithgrid_mode=False): the output hasround(n · factor)pixels along each axis, and its first and last pixels sample the input’s first and last pixels exactly.