Question

I am trying to produce Gaussian blobs of different intensities (black, gray, white) and contrasts but then, which parameter am I supposed to change in the code below?

Many thanks in advance!

imSize = 300;                           % image size: n X n
lamda = 10;                             % wavelength (number of pixels per cycle)
theta = 15;                              % grating orientation
sigma = 50;

imSize = 300;
% make linear ramp
X = 1:imSize;                           % X is a vector from 1 to imageSize
X0 = (X / imSize) - .5;                 % rescale X -> -.5 to .5
[Xm Ym] = meshgrid(X0, X0);
s = sigma / imSize;  

gauss = exp( -(((Xm.^2)+(Ym.^2)) ./ (2* s^2)) ); % formula for 2D gaussian
%%%%%%% NEW VARIABLES
trim = .005;                             % trim off gaussian values smaller than this
gauss(gauss < trim) = 0;                 % trim around edges (for 8-bit colour displays)

imagesc( gauss, [-1 1] );                        % display
colormap gray(256);
axis off; axis image;     % use gray colormap
Was it helpful?

Solution

Try one of these options -

gauss = 2*(gauss-0.5); %%// For a range of [-1 1];
imagesc( gauss, [-1 1] ); 

Or

gauss = gauss/2; %%// For a range of [0 0.5];
imagesc( gauss, [0 0.5] ); 

Or

gauss = 0.5*(gauss-1); %%// For a range of [-0.5 0];
imagesc( gauss, [-0.5 0] ); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top