1

We all know the separability property of a Gaussian Kernel. Are there any other Separable Blur Kernel which are common?

I'm looking for a kernel which decreases almost as fast as Gaussian Blur.

I can't use Gaussian Blur for various reasons. I would prefer something which doesn't require Trigonometric Functions (Else I would use some kind of "Windows" like Hann).

Thanks.

Royi
  • 4,640
  • 6
  • 46
  • 64
  • It's not clear that you are looking for - why doesn't a Gaussian work for you ? You do know that you can vary sigma in a Gaussian filter, to change the overall size of the kernel, right ? – Paul R Jan 14 '11 at 12:06

4 Answers4

4

From the comments to an earlier answer it sounds like you're working with the mistaken assumption that calculating the gaussian filter coefficients accounts for a significant part of the cost applying a gaussian filter. This is certainly not the case. The compute-intensive part is convolving the coefficients with the image. The cost of this is the same for any given NxN filter, regardless of how the coefficients are calculate.

Pseudo code for applying Gaussian (or any separable filter):

  • calculate 1D Gaussian (or other separable filter) coefficients
  • for each row
    • for each col
      • apply 1D coefficients in horizontal axis
  • for each row
    • for each col
      • apply 1D coefficients in vertical axis

(Note: in the above discussion I'm assuming a symmetrical (NxN) filter.)

Paul R
  • 208,748
  • 37
  • 389
  • 560
  • I know that, believe me. I really want an alternative to Gaussian Blur. This is a must. – Royi Jan 14 '11 at 14:25
  • 3
    @Drazick: but *why* ? You say it's for efficiency, yet I've just explained why it makes no difference if you switch to a different filter. Is there some other reason that you haven't mentioned ??? – Paul R Jan 14 '11 at 14:32
3

If you want the effect of a Gaussian blur without the cost, do a box blur multiple times. An infinite number of passes will replicate a Gaussian, but it only takes ~3 to be good enough to fool the eye.

If you implement the box blur by doing horizontal and vertical strips seperately, an extremely fast implementation is just to scan each strip of pixels and maintain a running total, adding the pixel radius/2 in front while subtracting the pixel radius/2 pixels behind and multiply by cached 1/radius to calculate the running average.

The great thing about this is that the radius of the blur has negligable effect on how long it takes to calculate.

GoatInTheMachine
  • 3,583
  • 3
  • 25
  • 35
0

Box filters are separable and quite common. But I really don't know what kind of filters you're looking for - for example, should it be rotational symmetric? If not, any convolution of a row- and column-blur filter is a separable blue filter.

Niki
  • 15,662
  • 5
  • 48
  • 74
  • It should have effect as close as possible to the Gaussian Blur. Circular Symmetric is welcome. Thanks. – Royi Jan 14 '11 at 12:21
  • 2
    "As close as possible to gaussian blur" - what's wrong with using gaussian blur then? – Niki Jan 14 '11 at 12:24
  • I want something easier to calculate. Better performance. – Royi Jan 14 '11 at 12:32
  • For the better performance part: http://stackoverflow.com/questions/98359/fastest-gaussian-blur-implementation – Agnius Vasiliauskas Jan 14 '11 at 12:52
  • I though about using Hann Window, yet it is based on trigonometric function which I would like to avoid. Any Polynomial Function with a close to results? – Royi Jan 14 '11 at 13:10
  • 3
    @Drazick: you only need to calculate the coefficients **once**. The cost of doing this is negligible. The compute-intensive part is applying those coefficients to the image. This will be the same (for a given kernel size) regardless of what type of filter you apply. Just use Gaussian and pre-compute the coefficients. – Paul R Jan 14 '11 at 13:46
  • Paul, I know that. I really can't use Gaussian Blur. I need an alternative. I know about precalculating the Coefficients and still I would prefer something which doesn't involve Exponents / Trigonometric Functions. Thank you. – Royi Jan 14 '11 at 14:28
  • @Drazick: you really need to state what you perceive the problem with using a Gaussian to be. It can't be efficiency, for the reasons stated above, so is there some other reason that you haven't mentioned ? – Paul R Jan 14 '11 at 14:33
  • @Drazik: A binomial filter is a good approximation to a gaussian, and it "doesn't involve exponents/trigonometric functions". (I doubt it would be more efficient, though.) – Niki Jan 14 '11 at 14:44
  • "yet it is based on trigonometric function which I would like to avoid" - then maybe you should here, for sine/cosine approximation functions: http://lab.polygonal.de/2007/07/18/fast-and-accurate-sinecosine-approximation/ – Agnius Vasiliauskas Jan 14 '11 at 16:10
  • 2
    The only reason not to use Gaussian but "As close as possible to Gaussian blur" can be that this is some sort of homework that require to use something other then Gaussian. – Ross Jan 15 '11 at 08:03
  • It's not an homework. I just wanted to have an alternative which doesn't use the exp function. I found one using Hann window, yet I'd like to avoid using trigonometric functions as well. – Royi Jan 28 '11 at 09:22
-2

One could use the known windows which are classic in 1D Signal Processing:
http://en.wikipedia.org/wiki/Window_function

A 2d Kernel could be created using Outer product.
Implementation should be as in any separable filter.

Royi
  • 4,640
  • 6
  • 46
  • 64