function img = gabor(mean, cpp, contrast, phase, sigma, orientation);

dim = round(max ( 1, real(2*(sqrt(2*log(mean*255*contrast))*sigma)) ));
X = ones(1,dim).*[-(dim-1)/2:1:(dim-1)/2];
Y = ones(dim,1);
T = Y*X;

val =  mean * contrast * sin(2.*pi.*(cpp).*T + phase);
g= fspecial('gaussian',[dim,dim],sigma);
g = g * (1/max(max(g)));
img = val .* g;
img=imrotate(img,orientation,'crop')+mean;
