pub(crate) fn upscale(
src: &mut Pixmap,
src_width: u16,
src_height: u16,
edge_mode: EdgeMode,
) -> (u16, u16)Expand description
Upsample a pixmap by 2x using linear interpolation with [0.75, 0.25] weights.
Uses separable passes: horizontal doubling followed by vertical doubling.
§Phase Alignment Theory
The downsampling [1,3,3,1]/8 filter creates a half-pixel offset. Its center of mass
is at position 2k + 0.5, not 2k. This means each downsampled pixel at discrete
position k represents a sample at continuous position 2k + 0.5.
When upsampling, we reconstruct pixels at positions 2k and 2k+1 from downsampled
pixels whose centers are at ..., 2k-1.5, 2k+0.5, 2k+2.5, ...
Interpolation weights are derived from linear interpolation based on distances:
- Position
2k: distance 0.5 from center at2k+0.5, distance 1.5 from center at2k-1.5→ weights: 0.75×pixel[k] + 0.25×pixel[k-1] - Position
2k+1: distance 0.5 from center at2k+0.5, distance 1.5 from center at2k+2.5→ weights: 0.75×pixel[k] + 0.25×pixel[k+1]