Stack Blur: Fast But Goodlooking

This is a compromise between Gaussian Blur and Box blur It creates much better looking blurs than Box Blur, but is 7x faster than my Gaussian Blur implementation. I called it Stack Blur because this describes best how this filter works internally: it creates a kind of moving stack (or maybe a "Tower of Hanoi" kind of structure) of colors whilst scanning through the image. This "tower" controls the weights of the single pixels within the convolution kernel and gives the pixel in the center the highest weight. The secret of the speed is that the algorithm just has to add one new pixel to the right side of the stack and at the same time remove the leftmost pixel. The remaining colors on the topmost layer of the stack are either added on or reduced by one, depending on if they are on the right or on the left side of the stack.

The Y-position of your mouse controls the radius of the blur in this example. At the bottom the radius is 90 pixels.

Usage in other libraries/projects:

I have written a port for JavaScript/Canvas

A C++ version of my algorithm is now part of Maxim Shemanarev's Anti-Grain Rendering Engine

Petr Kobalícek has written an improved port and included it in his graphics library Fog
The Stack Blur algorithm is also part of
KDE and it is used inside of Scribus

Here is an article called Fast image blurring with CUDA by ChaoJui adapting Stack Blur for parallel processing.

Evgeny Stepanischev has ported it to Google Go

Thomas Landspurg has written an iOS port

StackBlur is used inside the iPhone App Camera+

If you want to port this algorithm to any other language or platform I'd really appreciate it if you'd tell me so I can add a link to your project on this page. Also I expect that you give proper credits. Proper means - not only somewhere in the sourcecode where nobody can see it. For reference check Antigrain.

If you use the StackBlur algorithm in a commercial project, please consider a donation.