Original: http://blog.csdn.net/yao_zhuang/article/details/2532279
Download the cvgabor.cpp and cvgabor.h to your C + + project directory
Note: There are improved Cvgabor classes in my resources
RELATED LINKS are: http://download.csdn.net/source/490114
Special note: The use of this class requires OPENCV library support, how to configure the environment see: Http://www.opencv.org.cn/index.php/Template:Install
It has the following functions:
Create a specific direction and scale of Gabor
Generates a real part of the Gabor core that can be displayed or saved, and the imaginary part
The real, imaginary, or primary (Magnitude) response of the image
Responses can be saved in an XML file
[CPP]View PlainCopyprint?
- #include "Cvgabor.h"
- int main () {
- //Create a direction that is PI/4 and the scale is 3 Gabor
- double Sigma = 2*pi;
- Double F = sqrt (2.0);
- Cvgabor *gabor1 = new Cvgabor;
- Gabor1->init (PI/4, 3, Sigma, F);
- //Get the real part and show it
- Iplimage *kernel = Cvcreateimage (Cvsize (Gabor1->get_mask_width (), Gabor1->get_mask_width ()), IPL_DEPTH_8U, 1);
- Kernel = gabor1->get_image (cv_gabor_real);
- Cvnamedwindow ("Gabor Kernel", 1);
- Cvshowimage ("Gabor Kernel", Kernel);
- Cvwaitkey (0);
- //Load an image and display
- Iplimage *img = cvloadimage ( "d:/demo.jpg", Cv_load_image_grayscale);
- Cvnamedwindow ("Original Image", 1);
- Cvshowimage ("Original Image", IMG);
- Cvwaitkey (0);
- //Gets the real part of the Gabor filter response loaded into the image and displays
- Iplimage *reimg = Cvcreateimage (Cvsize (img->width,img->height), ipl_depth_8u, 1);
- Gabor1->conv_img (IMG, reimg, cv_gabor_real);
- Cvnamedwindow ("Real Response", 1);
- Cvshowimage ("Real Response", reimg);
- Cvwaitkey (0);
- Cvdestroywindow ("Real Response");
- //Gets the imaginary part of the Gabor filter response loaded into the image and displays
- Iplimage *reimg = Cvcreateimage (Cvsize (img->width,img->height), ipl_depth_8u, 1);
- Gabor1->conv_img (IMG, reimg, CV_GABOR_IMAG);
- Cvnamedwindow ("Imaginary Response", 1);
- Cvshowimage ("Imaginary Response", reimg);
- Cvwaitkey (0);
- Cvdestroywindow ("Imaginary Response");
- //Gets the module of the Gabor filter response loaded into the image and displays
- Iplimage *reimg = Cvcreateimage (Cvsize (img->width,img->height), ipl_depth_8u, 1);
- Gabor1->conv_img (IMG, reimg, CV_GABOR_MAG);
- Cvnamedwindow ("Magnitude Response", 1);
- Cvshowimage ("Magnitude Response", reimg);
- Cvwaitkey (0);
- Cvdestroywindow ("Magnitude Response");
- /*
- This response can be sampled as a 8-bit grayscale image. If you want the raw floating-point type of data, you can do this
- Iplimage *reimg = Cvcreateimage (Cvsize (img->width,img->height), ipl_depth_32f, 1);
- Gabor1->conv_img (IMG, reimg, CV_GABOR_MAG);
- However, these floating-point data cannot be displayed in the form of a grayscale image above, but it can be stored in an XML file.
- Cvsave ("Reimg.xml", (iplimage*) reimg, NULL, NULL, Cvattrlist (0,0));
- */
- }
Concept:
1. About wavelet transform:
A multi-resolution analysis tool provides an accurate and unified framework for the analysis and characterization of signals at different scales. Its principle is derived from the Fourier transformation! But it has more advantages than the traditional Fourier transformation, such as:
1) The wavelet transform can cover the whole frequency domain,
2) can reduce or remove the correlation between different characteristics of extraction by selecting the appropriate filter;
3) With zoom characteristics, the low frequency band can be used high frequency resolution and low time resolution, in the high frequency band can be used for low frequencies resolution and high time resolution  
4) wavelet transform has fast algorithm (Mallat wavelet analysis algorithm).
mentions that wavelet transforms must refer to wavelets, and simply, the function of integral 0 can be used as a wavelet function, and it can be obtained by a series of changes. the
wavelet transform is suitable for small wave function families and their corresponding scaling functions to decompose the original signals into different frequency bands. Generally speaking, the wavelet transform only recursive decomposition of the low-frequency portion of the signal to generate the next scale of the output of each channel. Layer decomposition (picture is not attached), such decomposition is often referred to as pyramid structure wavelet transform.
If the low-pass filter output is not only recursive decomposition, but also the output of the high-pass filter recursive decomposition, it is called wavelet packet decomposition. (tree shape) the
wavelet transform has good time-frequency localization, scale transformation and directional characteristics, and is a powerful tool for analyzing textures. &NBSP
2.Gabor transform
based on the simulation of the human visual system. By simulating the human visual system, retinal imaging can be decomposed into a set of filtered images, and each decomposed image can reflect the intensity variation in the local range of frequency and direction. Texture characteristics can be obtained through a set of multi-channel Gabor filters. The
Gabor transform is the design of the Gabor filter, and the design of the filter is the design of its frequency function (U,V) and the Gauss function parameter (one). In fact, the Gabor transform is to extract the local information of the signal Fourier transformation, using a Gauss function as a window function, because the Fourier transformation of a Gauss function is also a Gauss function, so the Fourier inverse transformation is also local.
through the selection of frequency parameters and Gaussian function parameters, Gabor transforms can select many texture features, but Gabor is non-orthogonal and has redundancy between different feature components, so it is not very efficient in the analysis of texture images.
from:http://blog.csdn.net/yangtrees/article/details/7437672
The application of learning Opencv--gabor function