I am trying to create a 2D image known as a variable size Gabor patch . Gabor's patch is best viewed as a convolution of a two-dimensional sine and 2D Gaussian.
The following is the function used to generate the code. The code has been ported from this tutorial for Matlab (suppose import numpy as np):
def gabor_patch(size, lambda_, theta, sigma, phase, trim=.005):
"""Create a Gabor Patch
size : int
Image size (n x n)
lambda_ : int
Spatial frequency (px per cycle)
theta : int or float
Grating orientation in degrees
sigma : int or float
gaussian standard deviation (in pixels)
phase : float
0 to 1 inclusive
"""
X0 = (np.linspace(1, size, size) / size) - .5
freq = size / float(lambda_)
phaseRad = phase * 2 * np.pi
Xm, Ym = np.meshgrid(X0, X0)
thetaRad = (theta / 360.) * 2 * np.pi
Xt = Xm * np.cos(thetaRad)
Yt = Ym * np.sin(thetaRad)
grating = np.sin(((Xt + Yt) * freq * 2 * np.pi) + phaseRad)
gauss = np.exp(-((Xm ** 2) + (Ym ** 2)) / (2 * (sigma / float(size)) ** 2))
gauss[gauss < trim] = 0
return grating * gauss
I would like the size of the Gabor patch to increase in proportion to the parameter size. In other words, I would like the size of the bounding box to determine the diameter of the patch. The problem is that this function does not behave this way. Instead, the bounding box grows in size, while the patch retains the same dimensions.
Example 1: size = 100

2: = 500

, . - ?
, , . !