spfunctions.py 文件源码

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

项目:spfeas 作者: jgrss 项目源码 文件源码
def convolve_gabor(bd, image_min, image_max, scales):

    """
    Convolves an image with a series of Gabor kernels

    Args:
        bd (2d array)
        image_min (int or float)
        image_max (int or float)
        scales (1d array like)
    """

    if bd.dtype != 'uint8':

        bd = np.uint8(rescale_intensity(bd,
                                        in_range=(image_min,
                                                  image_max),
                                        out_range=(0, 255)))

    # Each set of Gabor kernels
    #   has 8 orientations.
    out_block = np.empty((8*len(scales),
                          bd.shape[0],
                          bd.shape[1]), dtype='float32')

    ki = 0

    for scale in scales:

        # Check for even or
        #   odd scale size.
        if scale % 2 == 0:
            ssub = 1
        else:
            ssub = 0

        gabor_kernels = prep_gabor(kernel_size=(scale-ssub, scale-ssub))

        for kernel in gabor_kernels:

            # TODO: pad array?
            out_block[ki] = cv2.filter2D(bd, cv2.CV_32F, kernel)

            ki += 1

    return out_block
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号