Re: Gaussian blur kernels

Fabian Giesen <[email protected]>
Newsgroups gmane.games.devel.algorithms
Message-ID <[email protected]>
>> No... That isn't how it works; A downsample shares very little in
>> common with a blur.
> 
> Actually, they are both low-pass filters, so 
> downsampling-plus-upsampling is a form of blur. However, box filtering 
> (the traditional downsampling function) isn't actually all that great at 
> low-pass filtering, so it can generate aliasing, which a Gaussian filter 
> does not. (AFAICR, the Gaussian filter kernel shares some properties 
> with a sinc reconstruction kernel, and thus is "optimal" under certain 
> conditions/assumptions, but details are hazy).

All "practically implementable" downsampling filters cause some degree 
of aliasing, including sinc; the problem is that sinc has infinite 
support and decays quite slowly (as 1/x), so you have to use a windowing 
function: either do it explicitly with a good windowing function or 
implicitly choose a box window by just stopping the summation at some point.

Anyway, the problem with sinc is that it's very "ringy". Windowing 
functions help a bit, but it's still very obvious when you have 
high-contrast edges. Text on solid background is a good example - with 
sinc and other filters with a very steep frequency response, you can see 
"wavefronts" emanating from the edges of characters.

It's a continuum - the "simple" filters (box, triangle etc.) have no 
ringing but exhibit serious aliasing, sinc and other "good" lowpass 
filters (in terms of frequency response) have neglegible aliasing and 
tons of ringing.

Gaussians are smack in the middle - they're all-positive so there's no 
ringing and they have a decent frequency response.

As for the original question, you can build quite good 2D low-pass 
filters out of gaussians and downsampling, as long as you downsample 
*after* low-pass filtering. One example would be 5x5 Gaussian => 2x 
Downsample in both directions => 5x5 Gaussian => 2x Downsample in both 
directions => (more Gaussian blurs) => Upsample again. The result is not 
a gaussian kernel, but it "looks close enough". It's still a lot more 
expensive than the more usual downsample then blur, since you do the 
gaussian blur on a lot more pixels. What most people do for realtime 
appplications is just do the downsample first anyway, live with the 
aliasing, and do something else with the milliseconds of GPU time saved. :)

Anyway, if you care for it, you can even do the downsample/filter 
sequence "perfectly", in the sense that it really does give you the 
exact filter you want: look up Multirate Filter Banks. But again, nobody 
uses this for real-time applications, or at least I've never seen it. 
And of course, to do it properly, you need a better upsampling filter 
than bilinear too...

Kind regards,
-Fabian "ryg" Giesen

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
GDAlgorithms-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.