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

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

% Histogram comparison

imagesc(J);
plot(hist(reshape(J(:,1:100),1,20000),50))
hold on
plot(hist(reshape(J(:,101:200),1,20000),50),'k')
hold off

% Scale in texture

A = 125+15*randn(800,400);
B = imresize(125+15*randn(200,100),4,'nearest');
imagesc([A,B])
plot(hist(reshape(A,1,320000),50))
hold on
plot(hist(reshape(B,1,320000),50),'k')

% 1D Gabor functions

a = 10*pi*(0:1000)/(1000);
plot(cos(4*a).*(exp(- ( (a-5*pi).^2/(sqrt(2)*4)))));
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
imagesc(ones(400,1)*x);

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