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
评论列表
文章目录