Five-minute quickstart#
Downsample continuous data#
Use cubic-antialiasing as the default starting point for continuous-valued
data that is being made smaller:
import numpy as np
from splineops import resize
image = np.random.default_rng(0).random((512, 512), dtype=np.float32)
small = resize(
image,
output_size=(256, 256),
method="cubic-antialiasing",
)
Select spatial axes#
When an array includes batch or channel dimensions, identify only the spatial axes. Unselected axes are preserved exactly:
# H x W x C
small_rgb = resize(
rgb,
output_size=(256, 256),
axes=(0, 1),
method="cubic-antialiasing",
)
Choose a method#
Goal |
Method |
Note |
|---|---|---|
Continuous-data downsampling |
|
Recommended starting point. |
Faster downsampling |
|
Lower-order model. |
Upsampling |
|
Interpolation without projection. |
Categorical labels |
|
Nearest-neighbour semantics; validate the intended grid convention. |
Research configurations |
|
Exposes analysis and synthesis degrees directly. |
Reuse fixed geometry#
ResizePlan avoids repeating geometry setup when many arrays have the same
shape:
from splineops import ResizePlan
plan = ResizePlan(
input_shape=(64, 192, 192),
output_size=(32, 96, 96),
method="cubic-antialiasing",
)
coarse_frame = plan(frame)
Important semantics#
SplineOps resize uses one endpoint-aligned output grid. Calls that produce the same integer output shape therefore produce the same grid and result. Review the Resize guide before comparing another library: output size, coordinates, boundaries, and antialiasing methods must all match.
Next, see Volume downsampling for a complete 3-D workflow.