Skip to main content

Module gaussian_blur

Module gaussian_blur 

Source
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:

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.