Resize#
Functions for resizing N-dimensional data using standard spline interpolation, or projection-based antialiasing methods.
High-level helper#
The main entry point is resize(), which selects both
the spline degrees and (optional) antialiasing behavior via a single
method string.
- splineops.resize.resize(data: ndarray[tuple[int, ...], dtype[_ScalarType_co]], *, zoom_factors: float | Sequence[float] | None = None, output: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | dtype | None = None, output_size: Tuple[int, ...] | None = None, method: str = 'cubic') ndarray[tuple[int, ...], dtype[_ScalarType_co]]#
Resize an N-dimensional array using spline interpolation or an antialiasing projection preset.
This entry point selects both the algorithm and the spline degrees via a single
methodstring, and then delegates toresize_degrees().- Parameters:
data (ndarray) – Input array.
zoom_factors (float or sequence of float, optional) – Per-axis scale factors. Ignored if output_size is given.
output (ndarray or dtype, optional) – If an
ndarrayis supplied, the result is written in-place into that array and returned. If adtypeis supplied, a new array of that dtype is allocated and returned.output_size (tuple of int, optional) – Desired shape (overrides zoom_factors).
method (str) –
Preset selecting a specific (interp_degree, analy_degree, synthe_degree) triple.
Interpolation (no anti-aliasing, analy = -1):
"fast"– degree 0 (nearest)"linear"– degree 1"quadratic"– degree 2"cubic"– degree 3
Antialiasing (projection-based, recommended for down-sampling):
"linear-antialiasing"– (interp=1, analy=0, synthe=1)"quadratic-antialiasing"– (interp=2, analy=1, synthe=2)"cubic-antialiasing"– (interp=3, analy=1, synthe=3)
- Returns:
Resized data: either a new array or the one supplied via output.
- Return type:
ndarray
Advanced degrees API#
For full control over the three spline degrees (interpolation, analysis,
synthesis), use resize_degrees().
This exposes the underlying Muñoz/Unser projection framework directly
- splineops.resize.resize_degrees(data: ndarray[tuple[int, ...], dtype[_ScalarType_co]], *, zoom_factors: float | Sequence[float] | None = None, output: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | dtype | None = None, output_size: Tuple[int, ...] | None = None, interp_degree: int = 3, analy_degree: int = -1, synthe_degree: int | None = None, inversable: bool = False) ndarray[tuple[int, ...], dtype[_ScalarType_co]]#
Resize an N-dimensional array using explicit spline degrees.
This is the most general entry point: it exposes the three degrees:
interp_degree : degree of the interpolation B-spline φ (0..3)
analy_degree : analysis spline degree (-1..3, -1 = no projection)
synthe_degree : synthesis spline degree (0..3)
- Parameters:
data (ndarray) – Input array.
zoom_factors (float or sequence of float, optional) – Per-axis scale factors. Ignored if output_size is given.
output (ndarray or dtype, optional) – If an
ndarrayis supplied, the result is written in-place into that array and returned. If adtypeis supplied, a new array of that dtype is allocated and returned.output_size (tuple of int, optional) – Desired shape (overrides zoom_factors).
interp_degree (int, default 3) – Degree of the interpolation B-spline φ (0..3).
analy_degree (int, default -1) –
Degree of the analysis spline φ₁:
-1 → no projection (pure interpolation)
0..3 → projection-based resizing (antialiasing, equal-degree projection, etc.)
synthe_degree (int, optional) – Degree of the synthesis spline φ₂ (output space). Defaults to
interp_degree. Must be in [0..3] and <=interp_degree.inversable (bool, default False) – If True, use a size policy that ensures invertible zoom along each axis.
- Returns:
Resized data: either a new array or the one supplied via output.
- Return type:
ndarray
See also#
TensorSplineThe base class used internally for spline interpolation.