Gaussian Filter: A Gaussian Filter Smoothes An Image by Calculating Weighted Averages in A Filter Box
Gaussian Filter: A Gaussian Filter Smoothes An Image by Calculating Weighted Averages in A Filter Box
Gaussian Filter: A Gaussian Filter Smoothes An Image by Calculating Weighted Averages in A Filter Box
Note:
The image quality is optimal only for direct view by Acrobat Reader.
Browsers are sometimes not accurate. Please use Zoom=100%
1
Gaussian Filter
Blur Control
x/r 0 1 2 3
w(x) 1.0 0.6065 0.1353 0.0111
We can choose r=0.465·n. This results in a weight factor 0.1 at the outermost
pixel, at x=n , which seems to be reasonable. Less than 0.1 doesn´t make much
sense. For pixels on the diagonal corners of the xy-box the value is smaller.
The Gauss formula can be separated. This will make the calculations faster.
w(x,y) = e-(x·x+y·y) = w(x)·w(y) = e-x·x ·e-y·y
Another methods uses one source image, one array of the same size for the
accumulation and a sequence of shifted images. This shifted image is made once
for each position x,y for all pixels in the source image.
The author prefers the standard structure, because this is valid for any linear filter,
like softening, sharpening and contour finding filters, also for some effects which
use oszillations in the box.
A 5 x 5 binary Gaussian Filter, programmed mainly in Intel Assembly Language,
needs about one second for 1000 x 1000 pixels.
3
Binary Weighting
4
Binary Weighting Transfer Function
5
Arbitrary Filter Scaling
Generally spoken, we have raw positive weight factors Pi and raw negative weight
factors N i .
The actual filtering is done by scaled weight factors pi = Pi / S p and ni = N i / S n .
This scaling is based on the demand, that a uniform color area should deliver the
same color after filtering.
Example, as above :
S ip = 64
S in = 4·8 + 4·4 + 4·2 + 8·1 = 64
The center peak in the scaled matrix is +2 and the other negative values are
divided by 64 .
6
A General Sharpening Filter
The drawing shows the numbering and the weight factors for the kernel for a
sharpening filter, here with n=2. The algorithm works for any n ≥1. The total
number of elements is m= (2·n+1)2. The center weight factor fs[13]=2.0 is a
positive peak. The other weight factors fs[k] are calculated by a negative
Gauss Bell, according to the code below.
The sum of negative weight factors is -1.0 and the sum of all weight factors is
+1, therefore a uniformly colored area remains unfiltered, as required.
Gernot Hoffmann
December 20, 2002
Website: please load browser and click here
7