Gabor wavelet functions

Source: Internet
Author: User

1: Definition
http://en.wikipedia.org/wiki/Gabor_filter

There is considerable eviets (reviewed in maclennan 1991) that images in primary visual cortex (V1) are represented in terms of Gabor wavelets, that is, hierarchically arranged, gaussian-modulated sinusoids (equivalent to the pure states of quantum mechanics ). the Gabor-wavelet transform of a Two-dimen1_visual field generates a four-dimen1_field: Two of the dimensions are spatial, the other two represent spatial frequency and orientation. to represent this four-dimen1_field in Two-dimen1_cortex, it is necessary to ''slic'' the field, which gives rise to the columns and stripes of striate cortex. the representation is nearly optimal, as defined by the Gabor uncertainty principle (a generalization of the Heisenberg Uncertainty Principle to Information Representation and transmission ). time-Varying two-dimen1_visual images may be viewed as three-dimen1_functions of space-time, and it is possible that time-varying images are represented in vision areas by a three-dimen1_gabor-wavelet transform, which generates a Time-Varying five-dimen1_field (representing two spatial dimensions, spatial Frequency, spatial orientation and temporal frequency ). the effect is to represent the ''optic flow'' of images in terms spatially fixed, oriented grating patches with moving gratings. (See maclennan 1991 for more details .) finally, pribram provides evidence that Gabor representations are also used for controlling the generation of motor fields (see citations in maclennan 1997, p. 64 ).

Ii. Source Code
MATLAB source code:
Http://www.mathworks.com/matlabcentral/fileexchange/7287
C source code
Http://vision.ece.ucsb.edu/texture/software/

3. Texture example
Http://www.ux.uis.no /~ Tranden/brodatz.html

A Gabor filter is defined as the product of a Harmonic Function (cosine function in the following formula) and a Gaussian function. According to the signal and system theory, the convolution and product of the time-frequency domain are Fourier Transformations. The Fourier transform of the Gabor filter is the convolution of the harmonic and Gaussian Functions.

Gabor filter, where, in the above formula, λ represents the cosine function wavelength, θ represents the direction of the Gabor function parallel stripe normal [θ epresents the orientation of the normal to the parallel stripes ], σ is the phase compensation, σ is the Sigma of Gaussian envelope, and gamma is the space phase ratio and the elliptical rate in the Gabor function.

The following is the implementation in MATLAB:

 1 Function GB = Gabor_fn (Sigma, Theta, lambda, PSI, gamma)  2   3 Sigma_x = Sigma; 4 Sigma_y = SIGMA/ Gamma;  5   6 % Bounding box  7 Nstds = 3  ;  8 Xmax = max (ABS (nstds * sigma_x * Cos (theta), ABS (nstds * sigma_y * Sin (theta )));  9 Xmax = Ceil (max ( 1  , Xmax ));  10 Ymax = max (ABS (nstds * sigma_x * sin (theta), ABS (nstds * sigma_y * Cos (theta )));  11 Ymax = Ceil (max ( 1  , Ymax ));  12 Xmin =-xmax; ymin =- Ymax;  13 [X, y] = Meshgrid (xmin: xmax, ymin: Ymax );  14   15 % Rotation  16 X_theta = x * Cos (theta) + y * Sin (theta ); 17 Y_theta =-x * sin (theta) + y * Cos (theta );  18   19 GB = exp (-. 5 * (X_theta. ^ 2 /Sigma_x ^ 2 + Y_theta. ^ 2 /Sigma_y ^ 2 ). * Cos ( 2 * PI/Lambda * x_theta + psi );

========================================================== ======================================

Another MATLAB implementation function:

 1 Function [Gab] =Gaborcreate (m, n)  2   3 % Creation of Gabor mask  4 % Parameters-M = 0 , 1 ,... M- 1 Scales; n = 0 , 1 ,... N- 1  Orientation  5   6 %Creation of Gabor mask  7 % Parameters-M = 0 , 1 ,... M- 1 Scales; n = 0 , 1 ,... N- 1  Orientation  8   9 M = 4  ;  10 N = 3 ;  11 A = ( 0.4 / 0.05 ) ^ ( 1 /(M- 1  ));  12 Gab = cell ( 2 , 2  );  13 Count = 1  ;  14   15  For M = 1  : M  16        For N = 1  : N  17            18 W = a ^ m * 0.05  ;  19 Sigmax = (a + 1 ) * SQRT ( 2 * Log ( 2 )))/(2 * PI * a ^ m * (- 1 )* 0.05  );  20 Sigmay1 = (( 0.4 * 0.4 )/( 2 * Log ( 2 )))-(( 1 /( 2 * PI * sigmax) ^ 2  );  21 Sigmay =1 /(( 2 * PI * Tan (PI /( 2 * N ))* SQRT (sigmay1 )));  22 Theta = (N * PI )/ N;  23   24            For Ij = 1 : 2  25               For I = 1 : 3 26                 For J = 1 : 3  27 XB = a ^ (-m) * (I * Cos (theta) + J * Sin (theta ));  28 Yb = a ^ (-m) * (-I) * sin (theta) + J * Cos (theta ));  29 Phi1 = (- 1 / 2 ) * (XB * xb)/(sigmax * sigmax) + (Yb * Yb)/(sigmay * Sigmay )); 30                        If Ij = 1  31 Prob = I;  32                       Else  33 Prob = J;  34   End  35 Phi = ( 1 /( 2 * PI * sigmax * sigmay) * exp (phi1) * exp (2 * 2 * PI * w * Prob );  36 Gab1 (I, j) = Phi * a ^ (- M );  37   End  38   End  39 Gab {count, IJ} = Gab1;  40   41   End  42  43 Count = count + 1  ;  44   End  45 End
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.