Skip to content

Separable convolution

Convolve a grid with a 1D kernel applied on each axis. An N×N window costs O(N) per cell, not O(N²).

The general window operator on a grid:

  • a box kernel gives a local sum (or mean) — the neighbourhood total;
  • a Gaussian kernel gives smoothing.

It is the grid consumer the KDE splat feeds into, and the concrete realisation of the windowing principle on the image side.

Two passes (horizontal then vertical), each a "use gpu" gather kernel: every output cell reads its taps directly with clamp-to-edge boundaries. Box and Gaussian both match the CPU golden; a normalised Gaussian conserves total mass.

import {
convolveSeparableGpu, boxKernel, gaussianKernel,
} from 'intraspatial/gpu/spatial/convolveSeparable';
const smoothed = await convolveSeparableGpu(grid, w, h, gaussianKernel(2));
const localSum = await convolveSeparableGpu(grid, w, h, boxKernel(3)); // window radius 3

Status: ✅ implemented and validated (box + Gaussian, mass-conserving) · src/gpu/spatial/convolveSeparable.ts