4 ms·
One thing the article didn't mention is that a gaussian blur can be approximated with multiple passes of a box blur. Not sure how that would relate performance-
by dxhdr 3y ago
One thing the article didn't mention is that a gaussian blur can be approximated with multiple passes of a box blur. Not sure how that would relate performance-wise to the discussed stack blur algorithm. The code would probably be a bit simpler, anyway.
- evrimoztamur 3y agoFrom what I understand that’s what stack blur does, approximating the normal distribution.
- Jasper_ 3y agoStack 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/pixelbuffer/3951789-tentconvolve https://developer.apple.com/documentation/accelerate/vimage/...
- iainmerrick 3y agoDoes 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?
- a_e_k 3y agoThe 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.
- pornel 3y agoBox blur applied twice gives the same result. It will quickly converge to Gaussian.
- sudara 3y agoI'm interested in this idea. I think I got confused at some point and mistakenly thought box blur was a 2D kernel and so it wouldn't perform great. vImage does contain a box blur but I haven't checked its performance (I did check the tent blur and it was so-so...) https://developer.apple.com/documentation/accelerate/blurring_an_image?language=objc https://developer.apple.com/documentation/accelerate/blurrin...