maad.features.filter_bank_2d_nodc

maad.features.filter_bank_2d_nodc(frequency, ntheta, bandwidth=1, gamma=2, display=False, **kwargs)[source]

Build an ensemble of complex 2D Gabor filters with no DC offset.

A Gabor kernel is a Gaussian kernel modulated by a complex harmonic function. Harmonic function consists of an imaginary sine function and a real cosine function. Spatial frequency is inversely proportional to the wavelength of the harmonic and to the standard deviation of a Gaussian kernel. The bandwidth is also inversely proportional to the standard deviation [1]. These filters have been used to classify textures in images [4] and can be applied to characterize spectrograms to classify sounds [5].

Parameters:
frequency: 1d ndarray of scalars

Spatial frequencies used to built the Gabor filters. Values should be in the range [0;1]

ntheta: int

Number of angular steps between 0° to 90°

bandwidth: scalar, optional, default is 1

Spatial-frequency bandwidth of the filter. This parameters affect the resolution of the filters. Lower bandwidth result in sharper in filters with more details.

gamma: scalar, optional, default is 1

Gaussian window that modulates the continuous sine. For gamma = 1, the result is the same gaussian window in x and y direction (circle). For gamma <1, the result is an increased elongation of the filter size in the y direction (elipsoid). For gamma >1, the result is a reduction of the filter size in the y direction (elipsoid).

display: bool

Display a visualization of the filter bank. Default is False.

Returns:
params: 2d structured array

Parameters used to calculate 2D gabor kernels. Params array has 4 fields (theta, freq, bandwidth, gamma) This can be useful to interpret the result of the filtering process.

kernels: 2d ndarray of complex values

Complex Gabor kernels

References

[4]

Sifre, L., & Mallat, S. (2013). Rotation, scaling and deformation invariant scattering for texture discrimination. Computer Vision and Pattern Recognition (CVPR), 2013 IEEE Conference On, 1233–1240. DOI: 10.1109/CVPR.2013.163

[5]

Ulloa, J. S., Aubin, T., Llusia, D., Bouveyron, C., & Sueur, J. (2018). Estimating animal acoustic diversity in tropical environments using unsupervised multiresolution analysis. Ecological Indicators, 90, 346–355. DOI: 10.1016/j.ecolind.2018.03.026

Examples

>>> import maad

Build a filter bank using predefined parameters with the function maad.features.opt_shape_presets.

>>> from maad.features import filter_bank_2d_nodc, opt_shape_presets 
>>> opt = opt_shape_presets(resolution='med') 
>>> params, kernels = filter_bank_2d_nodc(opt['frequency'], opt['ntheta'], opt['bandwidth'], opt['gamma'], display=True) 

Alternatively, custom parameters can be provided to define the filter bank.

>>> from maad.features import filter_bank_2d_nodc 
>>> params, kernels = filter_bank_2d_nodc(frequency=(0.7, 0.5, 0.35, 0.25), ntheta=4, gamma=2, display=True)