Hacker News new | ask | show | jobs
by evrimoztamur 951 days ago
From what I understand that’s what stack blur does, approximating the normal distribution.
1 comments

Stack blur is a fast, discrete tent filter (weights are 1, 2, 3, 2, 1, normalize, it makes a triangle/tent shape). You can find tent filter blurs all over, including in Apple's own image processing library:

https://developer.apple.com/documentation/accelerate/vimage/...

Does that actually look good? I would have thought it would have really obnoxious diagonal artifacts.

Unless it can be tuned to behave like a repeated box blur (and therefore approximate a true Gaussian). A tent shape would just be two box blurs, right?

The convolution of a box filter with a box filter is a tent filter. So yes, a tent filter blur can be done with two box filter blurs.

And repeated box filters asymptotically approach a Gaussian filter, though in practice it converges very quickly. A single box filter can be thought of as a piece-wise constant approximation of a Gaussian filter. Two passes of box filters produce a piece-wise linear approximation (the tent). And three passes of box filters produce a piece-wise quadratic approximation. Four passes for a cubic approximation, etc. Usually, just the three box filters are used since they are close enough.

I'd need to look at the math in detail here, but I suspect that it's ultimately just cleverly interleaving the running sums for the two box filter to perform them in a single pass.

If so, it might be an interesting challenge to see if the idea can be extended to compute the higher quality three box filter approximation in a single pass.

Box blur applied twice gives the same result. It will quickly converge to Gaussian.