结合Gabor滤波器定义解读Python中函数filters.gabor_filter

最近用到Gabor滤波器,先了解一下基本概念,然后配合python自带的函数解读一下代码的含义。
概念部分参考:https://blog.csdn.net/forest_world/article/details/50926004
https://blog.csdn.net/jorg_zhao/article/details/47153115

一、Gabor滤波器

Gabor滤波器,最主要使用优势体现在对物体纹理特征的提取上。

二维Gabor基函数能够很好地描述哺乳动物初级视觉系统中一对简单视觉神经元的感受野特性。随着小波变换和神经生理学的发展,Gabor变换逐渐演变成二维Gabor小波的形式。Gabor滤波器对于图像的亮度和对比度变化以及人脸姿态变化具有较强的健壮性,并且它表达的是对人脸识别最为有用的局部特征,故在计算机视觉及纹理分析中得到广泛的应用。

如果从Fourier变换的角度来看,Gabor变换就是窗函数取高斯窗时的短时Fourier变换。
如果从小波变换的角度来看,Gabor变换就是小波基函数取Gabor基的小波变换。
在这里插入图片描述
其中a,b,σ1,σ2,ρ都是常数,我们称(X,Y)服从参数为a,b,σ1,σ2,ρ的∗∗二维正态分布∗∗,常把这个分布记作N(a,b,σ1,σ2,ρ)。
在这里插入图片描述

二、Gabor函数结合代码分析

在这里插入图片描述
波长(λ):它的值以像素为单位指定,通常大于等于2。但不能大于输入图像尺寸的五分之一。
方向(θ):这个参数指定了Gabor函数并行条纹的方向,它的取值为0到2π。
相位偏移(ϕ):它的取值范围为−π到π。其中,0、π度分别对应中心对称的center-on函数和center-off函数,而-π/2和π/2对应反对称函数。
长宽比(γ):空间纵横比,决定了Gabor函数形状的椭圆率(ellipticity)(ellipticity)。
当γ=1时,形状是圆的。当γ<1时,形状随着平行条纹方向而拉长。通常该值为0.5。
带宽(b):Gabor滤波器的半响应空间频率带宽。b和σ/ λ的比率有关,其中σ表示Gabor函数的高斯因子的标准差,如下:
在这里插入图片描述
σ 的值不能直接设置,它仅随着带宽b变化。带宽值必须是正实数,通常为1,此时,标准差和波长的关系为:σ=0.56λ。
带宽越小,标准差越大,Gabor形状越大,可见平行和抑制区条纹数量越多。

Python自带函数
gabor_filter(image, frequency, theta=0, bandwidth=1, sigma_x=None,  sigma_y=None, n_stds=3, offset=0, mode='reflect', cval=0)
'''
Parameters
    ----------
    image : 2-D array 输入图像
        Input image.
    frequency : float 谐波函数的空间频率,以像素位指定单位
        Spatial frequency of the harmonic function. Specified in pixels.
    theta : float, optional 这个参数指定了Gabor函数并行条纹的方向,它的取值为0到2π
        Orientation in radians. If 0, the harmonic is in the x-direction.
    bandwidth : float, optional 滤波器捕获带宽
        The bandwidth captured by the filter. For fixed bandwidth, `sigma_x`
        and `sigma_y` will decrease with increasing frequency. This value is
        ignored if `sigma_x` and `sigma_y` are set by the user.
    sigma_x, sigma_y : float, optional X和Y方向的标准差,决定了滤波器作用区域的大小
        Standard deviation in x- and y-directions. These directions apply to
        the kernel *before* rotation. If `theta = pi/2`, then the kernel is
        rotated 90 degrees so that `sigma_x` controls the *vertical* direction.
    n_stds : scalar, optional
        The linear size of the kernel is n_stds (3 by default) standard
        deviations.
    offset : float, optional 相位偏移
        Phase offset of harmonic function in radians.
    mode : {'constant', 'nearest', 'reflect', 'mirror', 'wrap'}, optional
        Mode used to convolve image with a kernel, passed to `ndi.convolve`
    cval : scalar, optional
        Value to fill past edges of input if `mode` of convolution is
        'constant'. The parameter is passed to `ndi.convolve`.
    
    Returns
    -------
    real, imag : arrays
        Filtered images using the real and imaginary parts of the Gabor filter
        kernel. Images are of the same dimensions as the input one.
'''

猜你喜欢

转载自blog.csdn.net/m0_37678226/article/details/90140840