Expand description
Gaussian blur filter implementation using multi-scale separable convolution.
This implementation uses a multi-scale approach for efficient blurring:
- Small blurs (σ ≤ 2): Direct separable convolution at full resolution
- Large blurs (σ > 2): Iterative downsample → blur → upsample pyramid
The algorithm automatically determines the optimal number of decimation levels
using variance analysis. Each 2× decimation applies a [1,3,3,1]/8 binomial filter
(adding variance = 3.0), then downsamples, reducing the remaining blur work needed.
This exploits the variance additivity property: σ²_total = σ²_downsample + σ²_blur.
Variance Addition Reference: The convolution of two Gaussians with variances σ₁² and σ₂² produces a Gaussian with variance σ₁² + σ₂². This fundamental property comes from probability theory and applies to Gaussian convolution in image processing. See:
- Torralba & Freeman, “Foundations of Computer Vision” (MIT Press), Section 2.2: https://visionbook.mit.edu/blurring_2.html#properties-of-the-continuous-gaussian
Constants§
- TRANSPARENT_
BLACK 🔒 - Transparent black pixel constant.
Functions§
- apply_
blur 🔒 - Apply Gaussian blur using multi-scale decimation and upsampling.
- convolve 🔒
- Apply separable Gaussian convolution with logical dimensions.
- convolve_
x 🔒 - Apply horizontal blur pass (1D convolution along x-axis).
- convolve_
y 🔒 - Apply vertical blur pass (1D convolution along y-axis).
- decimate_
weighted 🔒 - Blend 4 RGBA pixels using [1,3,3,1]/8 binomial weights.
- downscale 🔒
- Downsample image by 2x using separable [1,3,3,1]/8 binomial filter.
- downscale_
x 🔒 - Horizontal decimation pass using [1,3,3,1]/8 filter.
- downscale_
y 🔒 - Vertical decimation pass using [1,3,3,1]/8 filter.
- extend 🔒
- Extend a coordinate beyond image boundaries according to the edge mode.
- interpolate_
25_ 🔒75 - Blend 2 RGBA pixels using [0.25, 0.75] weights (right-weighted interpolation).
- interpolate_
75_ 🔒25 - Blend 2 RGBA pixels using [0.75, 0.25] weights.
- sample 🔒
- Sample a pixel with edge mode handling (generic implementation).
- sample_
x 🔒 - Sample a pixel with edge mode handling for horizontal sampling.
- sample_
y 🔒 - Sample a pixel with edge mode handling for vertical sampling.
- upscale 🔒
- Upsample a pixmap by 2x using linear interpolation with [0.75, 0.25] weights.
- upscale_
x 🔒 - Horizontal upsampling pass using [0.75, 0.25] interpolation with logical dimensions.
- upscale_
y 🔒 - Vertical upsampling pass using [0.75, 0.25] interpolation with logical dimensions.