I = 120*ones(200,200);
J = I + [15*randn(200,100),5*randn(200,100)];
figure(1); colormap(gray); imagesc(J)
K = I + [50*(randn(200,100)<0)-25,zeros(200,100)];
figure(1); imagesc(K)

K = I + [50*(rand(200,100)<.8)-40,50*(rand(200,100)<.5)-25];
figure(1); imagesc(K)

% Histogram comparison

figure(1); imagesc(J);
figure(2); 
hold off
plot(hist(reshape(J(:,1:100),1,20000),0:5:255))
hold on
plot(hist(reshape(J(:,101:200),1,20000),0:5:255),'k')
hold off
figure(1); figure(2);

% Scale in texture

A = 125+15*randn(800,400);
B = imresize(125+15*randn(200,100),4,'nearest');
figure(1); imagesc([A,B])
figure(2); 
plot(hist(reshape(A,1,320000),0:5:255))
hold on
plot(hist(reshape(B,1,320000),0:5:255),'k')
hold off

% 1D Gabor functions

a = 10*pi*(0:1000)/(1000);
figure(1); plot(cos(4*a).*(exp(- ( (a-5*pi).^2/(sqrt(2)*4)))));
figure(2); plot(cos(2*a).*(exp(- ( (a-5*pi).^2/(sqrt(2)*2)))));

% Markov patterns

x = 100*randn;
for i = 1:399 x = [x, x(i)+15*randn]; end
figure(1); imagesc(ones(400,1)*x);

y = x(400);
for i = 1:399 y = [y, y(i)+2*randn]; end
figure(2); imagesc(ones(400,1)*[x,y])