Skip to content

Instantly share code, notes, and snippets.

@saralilyb
Created April 21, 2019 16:35
Show Gist options
  • Save saralilyb/d57aab2fd4f28c652e6e68f8f4c83bbf to your computer and use it in GitHub Desktop.
Save saralilyb/d57aab2fd4f28c652e6e68f8f4c83bbf to your computer and use it in GitHub Desktop.
function gaborgenhelper(tilt, freq, title, sc, reso, phase, contrast, aspectratio)
if nargin < 4
reso = 400;
phase = 0;
sc = 50.0;
%freq = .07;
%tilt = 0;
contrast = 100.0;
aspectratio = 1.0;
end
% degrees to radians converter
deg2rad = @(degrees) degrees * pi / 180;
res = 1*[reso reso];
% phase = 0;
% sc = 50.0;
% freq = .07;
% tilt = 0;
% contrast = 100.0;
% aspectratio = 1.0;
nonsymmetric = 0;
tw = res(1);
th = res(2);
x=tw/2;
y=th/2;
sf = freq;
[gab_x, gab_y] = meshgrid(0:(res(1)-1), 0:(res(2)-1));
a=cos(deg2rad(tilt))*sf*360;
b=sin(deg2rad(tilt))*sf*360;
multConst=1/(sqrt(2*pi)*sc);
x_factor=-1*(gab_x-x).^2;
y_factor=-1*(gab_y-y).^2;
sinWave=sin(deg2rad(a*(gab_x - x) + b*(gab_y - y)+phase));
varScale=2*sc^2;
m=0.5 + contrast*(multConst*exp(x_factor/varScale+y_factor/varScale).*sinWave)'
size(m)
imshow(m);
% write file
%filename = strcat(title,'.png');
%imwrite(m, filename);
%drawnow;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment