Statistical Methods
Resample Label Arrays Without Inventing New Classes
Define the task
Distinguish class labels from continuous intensities before resizing an array. Interpolating numeric class codes can create values with no categorical meaning. Specify the interpolation order explicitly; nearest-neighbor sampling is a common label-preserving choice, while spline interpolation addresses a different task. Preserve original labels, their definitions and the intended physical extent. A larger output array does not create new measured detail.
Carry out the check
Record per-axis zoom factors, boundary mode and grid convention. SciPy's grid_mode distinguishes distance between sample centers from the full pixel extent. For five samples, the center-to-center extent is four index units, while the full pixel extent is five. Check the actual output shape and coordinate mapping rather than assuming every spacing scales exactly with a requested factor. Review thin structures and class counts after resampling; label preservation does not guarantee shape preservation.
Worked hypothetical example
Hypothetical example: two neighboring class codes are 1 and 3. Linear interpolation at their midpoint yields 2, which would falsely imply a third class if interpreted categorically. A nearest-neighbor rule returns one of the existing labels according to its coordinate and tie conventions. Test landmarks and label vocabulary in a tiny synthetic array before applying the same settings to a research pipeline. Store the resampling parameters with the output.
Method checked 23 November 2026 against Primary method documentation: zoom.