Fast spatial image filtering


This library encompasses fast separable FIR and IIR convolutions, IIR separable and arbitrarily oriented anisotropic spatial Gaussian and Gabor filtering. Unfortunatelly, not all of them are implemented for 3D sequence images, i.e. Image4d, currently. All routines are implemented purely in the spatial domain.

Axis-oriented separable convolutions

The library provides means to represent any general separable filter: either finite-response (FIR) or infinite-response (IIR) filter. In order to preserve the size of the convolved image, this image must be extended adequately. It is achieved by suppling user-defined extension arrays. These can be used directly, what amounts to, say, copying its content "before" and "after" each convolved line, or indirectly. In the latter case, the array is a set of indices. The final extension values are picked up from the convolved line at the positions specified in this array. This enables the user to extend the input image with mirrored boundary, for instance.

The module Separable Convolution gathers all structures and functions involved whose documentations are the proper sources of detailed information.

Specific filters

The library is primarily targeted at fast computation of a Gabor filter. This is the most demanding factor in the most of the energy-based and phased-based algorithms for the optical flow computation. The filtering is crucial not only from the time consumption point of view. Having fast and accurate filtering at hand will certainly have positive effect on the entire computing pipeline owing to the fact that filtering often forms the very first stage of it.

The library is also tightly focused on a Gaussian filter. Besides its day-to-day use in the field of image processing, Gauss filter is an essenatial part of any Gabor filter.

Hence, in the module tree of Linear Filters one may find predominantly only variants of Gauss and Gabor filters. Basically, there are FIR wrappers based on the separable convolution routines and several different IIR-based aproximations. Some fuctions also differ in the amount of available parameters to allow the computation of anisotropic or even arbitrarily-oriented filters. Original literature is cited in the documentation to provide the user with maximum information service possible.

In the same module tree, there are a few "supporting" modules. Functions in these sub-modules execute some helper computations such as determination of filter coefficients out of the filter specification, conversions and similar tasks. Many of them are not available outside the library and are documented only for the purpose of futher library development.

Arbitrarily-oriented Gaussian filters

We have functions allowing us for filtering with a truly general Gaussian filter. These are the ApplyANIGaussL(), ApplyANIGaussU() and ApplyANIGaussU2() (an improved version) functions which are based on the state-of-the-art (early 2008) knowledge in the literature. The demonstration to this topic can be found at the too. An extension to 3D sequence images is planned, not realized yet.

Arbitrarily-oriented Gabor filters

Recently, we added new functions for filtering with a general Gabor filter defined via the structure GaborFilter3D. The StagedGaborFiltering() function implements the staged scheme: modulation, Gaussian filtering using functions above and demodulation. The quality of the method is directly dependent of the quality of middle stage's Gaussian. We use the "L" or "U2" version of the Gaussian currently. The IIRedGaborFiltering() function approaches its result via several 1D direct IIR Gabor filterings.

Arbitrarily-oriented Gabor bank filtering

As of mid 2009 the optimized Gabor bank filtering was introduced in the library. The optimization is based on, firstly, separating all filters from the bank into many base 1D filterings and, secondly, reusing the same bases between two or four filters. Hence, the we use the term "base sharing" when refering to this optimization. The related demonstration page is at .

Several specifically tuned filtes can be computed with the Staged2GaborFiltering() and the Staged4GaborFiltering(). A bank of filters is first analyzed with the base sharing in the function PrepareGaborBank(), this forms a preparation/precomputation stage, and the optimized filtering is realized with either ApplyGaborBank() or ApplyGaborBank2(). The former uses the staged approach while the latter uses the direct approach.

Programing principles

The programmers showed their best to write really fast convolution routines, both general convolution and specialized IIR Gaussian filtering. The virtuozity was not exemplified by producing assembler routines or tuning the programs for specific platform by, for instance, expecting certain size of caches or physical memory access patterns. Instead, they adhered as much as possible to the following architecture-independent basic ideas:

These requirements can be translated into the following equivalents:

Owing to the good accuraccy demand and the nature of, especially, IIR coefficients, most of the functions support only floating-point voxel types.

Download and license information

The library is called LinearFilters. It is a property of the CBIA.

It is licensed under The GNU General Purpose License. It can be downloaded from the CBIA web pages: .

Software dependencies

This library is written in pure C++. It is directly dependent on LAPACK, the i4dcore ( 2D+t and 3D+t image representation library ) and i3dcore ( ) and libraries i3dcore further depends on. See the Software map.


This library was developed and is maintained by VladimĂ­r Ulman <>.