Fastest gaussian or box filter

Started by
4 comments, last by Vertex333 14 years, 9 months ago
I am looking for the fastest (who doesn't?) way to filter bitmaps (here it is GDI+) for a blurry look. I have seen that powerpoint 2007 (blur of the shadow of a vector element) performs quite well, so I want to know how I can do the same. I already tried the two gaussian and a box filter, but without well performance. It is possible to increase the filtersize and stuff like that, without a visible performance decrease in powerpoint. I can't say if they only use a box filtering approach, or somthing better. Nevertheless, I think they use GDI+ 1.1, which is not available on WinXP and therefore not interesting. I already tried the following: http://www.librow.com/articles/article-9 (performs not very well in contrast to box filter), http://www.geometrictools.com/LibImagics/Filters/Filters.html (I think an alterantive to FFT. Needs iterations for bigger window sizes, so not worth it for me), and a simple linear box filter, which may enough?!? I already looked up some graphics libraries. However, I gave up, since I was not able to extract the main gaussian approach/algorithm. Could an FFT approach (can't really find one) be faster? I will change my filter size up to 200 pixels, bitmap sizes may be a bit smaller than screen resolutions. Thx for any help! Vertex
Advertisement
Box filtering can be very fast if you use a precalculated summed area table, stackblur is another fast alternative.
Thx!

Does anyone know another method, which is faster than stackblur (which I think/tested is the fastest for me till now)?
How do you calculate and display the blurred image? Do you cache the result? Do you use alpha blending or a simple blit on a plain background?

Stackblur is pretty fast, check out the last demo on this page.

Also do you have to use GDI+? Summed area tables can be generated relatively fast on the GPU and alpha blending is extremely cheap. See "Fast Summed-Area Table Generation and its Applications".

For large images it might be possible to speed-up stackblur by using several threads, each thread blurring a bunch of scan-lines (horizontally and when finished vertically).
AFAIK the fastest blurs are achieved in theory by,
1 - Using a separable kernel; K(x,y)=Kx(x)*Ky(y). This means you can blur horizontally and then vertically, independently; this reduces the 2d problem to 'rows + columns' 1d problems. Gaussian and box blurs are separable.
2 - Use FFT-based convolution for the individual 1d problems.

I can't point you to a ready-made implementation, unfortunately. However, there's a really fast FFT implementation known as FFTW.
Quote:Original post by Kambiz
How do you calculate and display the blurred image? Do you cache the result? Do you use alpha blending or a simple blit on a plain background?

Stackblur is pretty fast, check out the last demo on this page.

Also do you have to use GDI+? Summed area tables can be generated relatively fast on the GPU and alpha blending is extremely cheap. See "Fast Summed-Area Table Generation and its Applications".

For large images it might be possible to speed-up stackblur by using several threads, each thread blurring a bunch of scan-lines (horizontally and when finished vertically).

I use GDI+. I can't use the GPU. I do compare timings only on simple memory, so any copy or stuff like that won't be compared. Threading would be nice, but I can't use it too. What I use at the moment is SSE2. Nevertheless I am struggeling with the devision.


Quote:Original post by Emergent
AFAIK the fastest blurs are achieved in theory by,
1 - Using a separable kernel; K(x,y)=Kx(x)*Ky(y). This means you can blur horizontally and then vertically, independently; this reduces the 2d problem to 'rows + columns' 1d problems. Gaussian and box blurs are separable.
2 - Use FFT-based convolution for the individual 1d problems.

I can't point you to a ready-made implementation, unfortunately. However, there's a really fast FFT implementation known as FFTW.

And thats the problem. To find at least a usable sample with FFT I only found this FFT alternative, listed in first post (performance is bad).

Thx,
Vertex

[Edited by - Vertex333 on July 24, 2009 4:19:39 AM]

This topic is closed to new replies.

Advertisement