2010-09-06
This article describes an approach for efficient two-dimensional convolution with arbitrary circularly symmetric convolution kernels. A 2-d Gaussian kernel is linearly separable; the convolution can be split into a horizontal convolution followed by a vertical convolution. This makes 2-d Gaussian convolution relatively cheap, computationally, and “Gaussian blur” has become, partially for this reason, a popular operation in image processing. No other circularly symmetric convolution kernel is linearly separable. But this is only true when the kernel is limited to real numbers. This article introduces complex-valued convolution kernels that are both circularly symmetric and linearly separable, and goes on to show how these can be used to produce arbitrary circularly symmetric 2-d convolutions by 1-d convolutions, in contrast to the use of 2-d Fast Fourier Transform (FFT). Special focus is given to implementation of circular convolution, or convolution with a solid disc, which is useful for simulation of bokeh of camera lenses with fully open apertures.

A Gaussian convolution kernel, used in Gaussian blur (black = -maximum value, grey = 0, white = maximum value)
To produce circularly symmetric 2-d convolution, the condition that the 1-d kernel function
must satisfy is
. The condition may be broken down into a magnitude condition and a phase condition that must both be satisfied. The magnitude condition reads
, meaning that the kernel must have a Gaussian function as its magnitude function. Because in multiplication of complex numbers the phases are summed, the phase (argument) condition reads
, with the shorthand
. The only family of functions to satisfy this is
. The kernel function can be constructed as the product of a Gaussian function, here called the envelope, and a complex phasor with
as its argument. In one dimension these kernels have the form
, where
is the imaginary unit,
is the spatial coordinate,
is the spatial scaling constant of the envelope, and
is the spatial scaling constant of the complex phasor. In two dimensions the form is
,
being the coordinate in the other dimension. Let’s see what these look like.
These forms are not normalized to preserve average intensity in image filtering, but to give a value of 1 for
. Arbitrary circularly symmetric shapes can be constructed by a weighted sum of the real parts and imaginary parts of complex phasors of different frequencies. Fourier series is the standard approach for such designs. These give a repetitive pattern, but the repeats could be diminished by adjusting the spatial scale of the envelope. As necessary, sloping of the envelope can be compensated for in the weights of the sum, but simultaneous optimization of both will give the best results, as it can take advantage of that the envelopes need not be the same for each of the component kernels.
Let’s try a 5-component square wave approximation, designed manually with the Fourier series applet of Paul Falstad.
The formula for this series is
. A bit of scaling (by 0.9) and shifting (by -0.01) was then done to make the ripples go evenly around the zero level and to avoid values greater than 1.
This is a pretty good indicator of the capabilities of this approach. The weighted component kernels were:
By lowering the spatial scale of the magnitude part of each component kernel, one gets a result like this:
Not so bad! The halos would need to be eliminated, and the disk is also fading a bit toward the edges.
I searched for better circular kernels by global optimization with an equiripple cost function, with the number of component kernels and the transition bandwidth as the parameters. Transition bandwidth defines how sharp the edge of the disk is. The sharper it is, the more ringing there will be both inside and outside the disk. A transition bandwidth setting of 1 means that the width of the transition is as large as the radius of the disk inside. Below, 1-d component kernel formulas are given for a pass band spanning
and a dual stop band spanning
.
The last one of the above, with 5 component kernels, is good enough for practical applications as the ripple is as small as 1/250, about as much as the least significant bit for 8-bits-per-channel graphics, so invisible in almost all situations. As the number of components is increased, the components have an increasingly large weighted amplitude, as much as 36 times their sum for the 5-component system. This may become a practical problem if one aims for convolution kernel shapes with sharp transitions. Here is one more, as a bonus:

Number of components: 6, transition bandwidth: 0.200000, ripple: ±0.001935. Component 0: (cos(x*x*1.981960) * -62.773778 + sin(x*x*1.981960) * 99.694943) * exp(-5.029513 *x*x) Component 1: (cos(x*x*6.159438) * 74.703895 + sin(x*x*6.159438) * 41.255198) * exp(-5.134785* x*x) Component 2: (cos(x*x*9.531306) * 0.154676 + sin(x*x*9.531306) * -84.608620) * exp(-6.171939* x*x) Component 3: (cos(x*x*12.618627) * -23.197236 + sin(x*x*12.618627) * 33.922147) * exp(-5.3924 39*x*x) Component 4: (cos(x*x*14.751538) * 12.326634 + sin(x*x*14.751538) * -4.453788) * exp(-5.04584 3*x*x) Component 5: (cos(x*x*18.798966) * -0.216125 + sin(x*x*18.798966) * -0.079862) * exp(-2.24716 8*x*x)





































































,
, and
. If
you can always swap the two numbers.
.
is a very large negative number, then
.
. These conditions are necessarily satisfied if
,
, and
can be calculated.
.
.
and
are called Gaussian logarithms, because Carl Friedrich Gauss was the first to publish printed tables of them.

















of the area of the probability density function lies more than
standard deviations away from the mean. We can do better, if we know that the distribution is bounded and we know the bounds.
be a random variable bounded by
, where
. Given the first two moments,
and
, of its probability distribution, a sharp lower bound to
, where
, is given by:
a constant both bounded by
, where
be a random variable otherwise equal to 
and
cannot be determined knowing only
and 
I measured these impulse responses from the home audio system of my friend Mikko Nelo at his city flat (check the pic for an overview. There might have been a subwoofer somewhere too, but I don’t remember…). Hehe, at least the bass is there. Miniature microphones were plugged into my ears, a minidisc recorder operated as a pre-amp and a laptop I borrowed from work as the player/recorder. A lengthy ![[Maple Math]](http://yehar.com/blog/wp-content/uploads/2009/09/hilbert1.gif)







