Log in

View Full Version : Fractional Box Filter


a uio
31st October 2008, 20:21
Hi,

Normally a simple box filter is quite discrete. It can have radius 1 pixel, 2 pixels, 3 pixels, etc. But not a radius of 2.3 pixels. I've found this lack of continuity to be inconvenient at times, and had the idea of adding a 1 pixel wide "ramp" or "half tent" on the ends of the box to support fractional widths. Seems to function fairly well and I even came up with an implementation that preserves the speediness of the regular box filter.

I was curious about people's opinions on

a) is this reasonable or fairly common thing to do?
b) are there other approaches to making a continuous box filter?

Cheers,
A

MfA
5th November 2008, 16:17
For a scale down ratio of between 0.5 and 1 this is bilinear filtering of course.

Using a square area model for pixels (which is essentially what this is about) is common ... and it's reasonable in as far as it's efficient. Image quality wise it's not a good idea, because your filter footprint is isotropic which creates jaggies.

There are many ways to Rome ... I think you can do this with a combination of box filtering, nearest neighbor filtering and bilinear filtering although with a filter as simple as this hitting L1 is the most important part of making it as fast as possible. So you wouldn't really want to do it that way.

a uio
5th November 2008, 23:22
One of my favorite uses of a box filter is applying three iterations to approximate a Gaussian, whether for filtering images or audio or any data. The extension above makes this continuous for fractional radii, just like a real Gaussian, while still uber fast just like the standard box. Very handy.

Cheers,
A

MfA
6th November 2008, 01:57
The whole gaussian filtering by box filtering seems a throw back from a time when multiplies were expensive to me. You can implement a narrow gaussian filter directly and a wide gaussian filter with 2 IIR filters ... both these methods are very fast, probably faster than using iterative box filtering.

a uio
6th November 2008, 06:39
implement a wide gaussian filter with 2 IIR filters.

You wouldn't happen to have any pointers to implementations of the IIR method, would you? I would love see how it works.

Cheers,
A

MfA
6th November 2008, 07:22
CIMG has a C++ implementation (deriche filter).

a uio
7th November 2008, 06:18
CIMG has a C++ implementation (deriche filter).

Thanks for the pointer! Nothing like a little code to explain something :) I also checked out the chapter on recursive filters in www.dspguide.com.

Cheers,
A