function outImg = insertGabor (params, inImg) % an example to use structure variable to organize input arguments % written by YW, 2/2014 % Use meshgrid to define matrices x and y that range from -pi to pi; [x,y] = meshgrid (linspace (-pi, pi, params.n)); if ~exist('inImg', 'var') inImg = zeros (params.n); end % Creat an oriented 'ramp' matrix as a linear combination of x and y. For % example, when parms.orientation =0, cos=1 and sin=0 so ramp=x. When % params. orientation is pi/2, then cos =0 and sin=1 so ramp=y. ramp = cos (params.orientation)* (x-params.center(1))+sin(params.orientation)*(y-params.center(2)); % Sinusoidal carrier is a sinusoid on the matrix 'ramp' sinusoid = params.contrast*sin(params.sf*ramp-params.phase); % Gaussian envelope Gaussian = exp(-((x-params.center(1)).^2+(y-params.center(2)).^2)/params.width^2); % A gabor is the product of the sinusoid and the Gaussian Gabor = sinusoid.*Gaussian; outImg = inImg+Gabor;