百度空间 | 百度首页 
 
查看文章
 
Gabor wavelets transform 【Gabor 小波变换】
2009-06-12 11:26
一:定义
http://en.wikipedia.org/wiki/Gabor_filter

There is considerable evidence (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-dimensional visual field generates a four-dimensional field: two of the dimensions are spatial, the other two represent spatial frequency and orientation. To represent this four-dimensional field in two-dimensional cortex, it is necessary to ``slice'' 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-dimensional visual images may be viewed as three-dimensional functions of space-time, and it is possible that time-varying images are represented in vision areas by a three-dimensional Gabor-wavelet transform, which generates a time-varying five-dimensional 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).

二:源码
MATLAB源码:
http://www.mathworks.com/matlabcentral/fileexchange/7287
C源码
http://vision.ece.ucsb.edu/texture/software/

三:纹理示例
http://www.ux.uis.no/~tranden/brodatz.html


Gabor 滤波器定义为:其脉冲响应为一个谐波函数(即下式中的余弦函数)和一个高斯函数的乘积。根据信号与系统理论,时频域的卷积和乘积互为傅里叶变换。Gabor滤波器的傅里叶变换为谐波和高斯函数各自傅里叶变换的卷积。

Gabor 滤波器,

g(x,y;\lambda,\theta,\psi,\sigma,\gamma)=\exp\left(-\frac{x'^2+\gamma^2y'^2}{2\sigma^2}\right)\cos\left(2\pi\frac{x'}{\lambda}+\psi\right)

其中,x' = x \cos\theta + y \sin\theta\,
          y' = -x \sin\theta + y \cos\theta\,

在上式 ,λ代表余弦函数波长,θ代表Gabor函数平行条纹法线的方向【θ epresents the orientation of the normal to the parallel stripes】,ψ为相位补偿,σ为高斯包络的sigma,γ为空间相位比和Gabor函数中的椭圆率

以下是MATLAB中实现:

function gb=gabor_fn(sigma,theta,lambda,psi,gamma)

sigma_x = sigma;
sigma_y = sigma/gamma;

% Bounding box
nstds = 3;
xmax = max(abs(nstds*sigma_x*cos(theta)),abs(nstds*sigma_y*sin(theta)));
xmax = ceil(max(1,xmax));
ymax = max(abs(nstds*sigma_x*sin(theta)),abs(nstds*sigma_y*cos(theta)));
ymax = ceil(max(1,ymax));
xmin = -xmax; ymin = -ymax;
[x,y] = meshgrid(xmin:xmax,ymin:ymax);

% Rotation
x_theta=x*cos(theta)+y*sin(theta);
y_theta=-x*sin(theta)+y*cos(theta);

gb=exp(-.5*(x_theta.^2/sigma_x^2+y_theta.^2/sigma_y^2)).*cos(2*pi/lambda*x_theta+psi);

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

另外一个MATLAB实现函数:

function [gab]=gaborcreate(M,N)

%CREATION OF GABOR MASK
%Parameters -m=0,1,...M-1 scales ; n=0,1,...N-1 orientation

%CREATION OF GABOR MASK
%Parameters -m=0,1,...M-1 scales ; n=0,1,...N-1 orientation

M=4;
N=3;
a=(0.4 / 0.05)^(1/(M-1));
gab=cell(2,2);
count=1;

for m=1:M
     for n=1:N
        
         W=a^m * 0.05;
         sigmax=((a+1)*sqrt(2 * log(2))) / (2 * pi * a^m * (a-1) * 0.05);
         sigmay1=((0.4 *0.4) / (2*log(2))) - (( 1 / (2 *pi* sigmax))^2);
         sigmay=1 / ((2* pi * tan(pi/(2*N)) * sqrt ( sigmay1)));
         theta=(n*pi)/N ;

         for ij=1:2
            for i=1:3
              for j=1:3
                    xb=a^(-m) * (i*cos(theta) + j*sin(theta));
                    yb=a^(-m) * ((-i)*sin(theta) + j*cos(theta));
                    phi1=(-1/2) * ((xb*xb)/(sigmax*sigmax) + (yb*yb)/(sigmay*sigmay));
                     if ij==1
                        prob=i;
                    else
                        prob=j;
                    end
                    phi=(1/(2*pi*sigmax*sigmay)) * exp(phi1) * exp(2*2*pi*W*prob);
                    gab1(i,j)=phi* a^(-m);
              end
          end
         gab{count,ij}=gab1;

        end

          count=count+1;
      end
end


类别:matlab 源程序 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu