gabor_filter_bank.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:spfeas 作者: jgrss 项目源码 文件源码
def prep_gabor(n_orientations=32, sigma=3., lambd=10., gamma=.5, psi=1., kernel_size=None, theta_skip=4):

    """
    Prepare the Gabor kernels

    Args:
        n_orientations (int)
        sigma (float): The standard deviation.
        lambd (float): The wavelength of the sinusoidal factor.
        gamma (float): The spatial aspect ratio.
        psi (float): The phase offset.
        kernel_size (tuple): The Gabor kernel size.
        theta_skip (int): The `theta` skip factor.
    """

    if not isinstance(kernel_size, tuple):
        kernel_size = (15, 15)

    # Prepare Gabor kernels.
    kernels = list()

    # kernel = resize(gabor_kernel(frequency,
    #                              theta=theta,
    #                              bandwidth=lambd,
    #                              sigma_x=sigma,
    #                              sigma_y=sigma,
    #                              offset=psi)

    for th in range(0, n_orientations, theta_skip):

        # The kernel orientation.
        theta = np.pi * th / n_orientations

        kernel = cv2.getGaborKernel(kernel_size, sigma, theta, lambd, gamma, psi, ktype=cv2.CV_32F)

        kernel /= 1.5 * kernel.sum()

        kernels.append(np.float32(kernel))

    return kernels
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号