number_scales = 5
number_orientations = 8
N = 128

def getFilter(f_0, theta_0):
    scale_bandwidth = 0.996 * math.sqrt(2 / 3)
angle_bandwidth = 0.996 * (1 / math.sqrt(2)) * (np.pi / number_orientations)
extent = np.arange(-N / 2, N / 2 + N % 2)
x, y = np.meshgrid(extent, extent)
mid = int(N / 2)
theta = np.arctan2(y, x)
center_angle = (np.pi / number_orientations * theta_0 if f_0 % 2 else np.pi /
    number_orientations * (theta_0 + 0.5))
costheta = np.cos(theta)
sintheta = np.sin(theta)
ds = sintheta * math.cos(center_angle) - costheta * math.sin(center_angle)
dc = costheta * math.cos(center_angle) + sintheta * math.sin(center_angle)
dtheta = np.arctan2(ds, dc)
orientation_component = np.exp(-0.5 * (dtheta / angle_bandwidth) ** 2)
raw = np.sqrt(x ** 2 + y ** 2)
raw[mid, mid] = 1
raw = np.log2(raw)
center_scale = math.log2(N) - f_0
draw = raw - center_scale
frequency_component = np.exp(-0.5 * (draw / scale_bandwidth) ** 2)
frequency_component[mid, mid] = 0
return frequency_component * orientation_component
Реализация банка фильтров log Gabor