Gaussian filter

There are many other linear smoothing filters, but the most important one is the Gaussian filter, which applies weights according to the Gaussian distribution (d in the figure).

The key parameter is σ, which controls the extent of the kernel and consequently the degree of smoothing (and how long the algorithm takes to execute). More aggressive than the mean filter, the Gaussian filter deals with random noise more effectively (Figures 1d and 2d). But it still simply mixes the noise into the result and smooths indiscriminately across edges. Again, it is imperative to remove spikes before applying this filter.

Optimizing
It's important that the Gaussian kernel is not too small — it must be large enough to 'fade out' without sharp edges. Edges have large bandwidth, so they introduce aliasing artifacts into the result after convolution.

The optimal value for &sigma; is between about 0.8 and 1.0.

Implementation in Python
We can make a Gaussian kernel in Python:



But we don't really need to — we can just use the SciPy signal processing library: