Sign in to follow this  
Vertex333

Fastest gaussian or box filter

Recommended Posts

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this