Gabor generation

what did he mean when he says in the commentars that it could be written in a nicer way? what is wrong with this actual verison?

if 1
    % Definition of a Gabor patch as Matlab grayscale matrix 'm' with
    % proper sign -- a value of zero in m denotes zero contrast at that
    % pixel location: This is ugly cut & copy & paste code which could be
    % written much nicer by a person with good taste ;-)
    res = 2*[s s];
    phase = 0;
    sc = 5;
    freq = 0.05;
    tilt = 0;
    contrast = 5;
    x=res(1)/2;
    y=res(2)/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=contrast*(multConst*exp(x_factor/varScale+y_factor/varScale).*sinWave)';
else
    % Old style: Sine gratings with pretty hard contrast:
    [x,y]=meshgrid(-s:s, -s:s);
    angle=0*pi/180; % 30 deg orientation.
    f=0.1*2*pi; % cycles/pixel
    a=cos(angle)*f;
    b=sin(angle)*f;
    m=sin(a*x+b*y);
end

it is from the Garborium function, [function GarboriumDemo(ngabors, internalRotation)]

I don’t think there is anything “wrong” with it. Just that the comments could be a bit more informative I assume.

You might also want to have a look at procedural drawing

If you are intersted in efficient Gabor drawing.

P