util.grandom

util.misc

# util.kernel¶

Functions for dealing with the kernel matrices of linear filters.

glimpse.util.kernel.DrawGaborAsLine(orient, num_orientations=8, kwidth=11, shift_orientations=False, line_width=1)

Draw the line corresponding to a given Gabor.

The generated line is phase independent.

Parameters: norientations (int) – Number of edge orientations. kwidth (int) – Width of kernel in pixels. shift_orientations (bool) – Whether to rotate Gabor through a small angle. line_width (int) – Width of drawn line in pixels. 2D ndarray of float
glimpse.util.kernel.MakeGaborKernel(kwidth, theta, gamma=0.59999999999999998, sigma=None, phi=0, lambda_=None, scale_norm=True)

Create a kernel matrix by evaluating the 2-D Gabor function.

Parameters: kwidth (odd int) – Width of the kernel. theta (float) – Orientation of the (normal to the) preferred frequency. gamma (float) – Aspect ratio of Gaussian window (gamma = 1 means a circular window, while 0 < gamma < 1 means the window is elongated). sigma (float) – Standard deviation of Gaussian window (1/4 the wavelength is a good choice, so that the window covers approximately two full wavelengths of the sine function). phi (float) – Phase offset (phi = 0 detects white edge on black background, phi = $$\pi$$ detects black edge on white background). lambda (float) – Wavelength of sine function (2/5 * kwidth is a good choice, so that the kernel can fit 2 1/2 wavelengths total). scale_norm (bool) – If true, the kernel vector will be scaled to have unit norm. kernel matrix 2D ndarray of float
glimpse.util.kernel.MakeGaborKernels(kwidth, num_orientations, num_phases, shift_orientations, **args)

Create a set of 2-D square kernel arrays, whose components are chosen according to the Gabor function.

Parameters: kwidth (odd int) – Width of kernel. num_orientations (int) – Number of edge orientations (orientations will be spread between 0 and $$\pi$$). num_phases (int) – Number of Gabor phases (a value of 2 matches a white edge on a black background, and vice versa). shift_orientations (bool) – Whether to rotate Gabor through a small angle (a value of True helps compensate for aliasing). scale_norm (bool) – If true, then the kernel vector is scaled to have unit norm. kernel arrays 4D ndarray of float
glimpse.util.kernel.MakeLanczosKernel()

Construct a smoothing filter based on the Lanczos window.