


% build pics

% type 1 -- bipolar
a = zeros(320,240);
a(1:160,:) = 1;

pic = zeros(320,240,8);
pic(:,:,1) = a;

a = zeros(320,240);
a(1:2:320,1:240) = 1;

pic(:,:,2) = a;

% type 2 -- equal distribution
a = rand(320,240); % equal distribution

pic(:,:,3) = a;

b = [1:255];
b = repmat(b,1,302);
a = zeros(320,240);
a(:) = b(1:(320*240));
a = a/255;

pic(:,:,4) = a;

% type 3 -- normal distribution

a = randn(320,240);
mina = min(a(:));
a = a + abs(mina);
maxa = max(a(:));
a = a / maxa;

pic(:,:,5) = a;

a = randn(320,240);
mina = min(a(:));
a = a + abs(mina);
maxa = max(a(:));
a = a / maxa;

pic(:,:,6) = a;

% type 4 -- dark-skewed

a = randn(320,240);
mina = min(a(:));
a = a + abs(mina);
maxa = max(a(:));
a = a / (maxa * 3);

pic(:,:,7) = a;

b = [1:255];
c = [];
for i=1:257
    for j = 1:257-i
        c = [c i-1];
    end
end
b = repmat(c,1,3);

a = zeros(320,240);
a(:) = b(1:(320*240));
a = a/255;

pic(:,:,8) = a;

figure;

for i=1:8
    [im1, im2] = query(pic(:,:,i), pic);
    
    subplot(3,8,i), imshow(pic(:,:,i))
    subplot(3,8,i+8), imshow(im1)
    subplot(3,8,i+16), imshow(im2)
end
    
img=imread('cof1.jpg');
img = imresize(img,[320 240]);
img = sum(img,3);
img = img / max(img(:));

uimg(:,:,1) = img(:,:);

img=imread('cof2.jpg');
img = imresize(img,[320 240]);
img = sum(img,3);
img = img / max(img(:));

uimg(:,:,2) = img(:,:);

img=imread('cthulhu.jpg');
img = imresize(img,[320 240]);
img = sum(img,3);
img = img / max(img(:));

uimg(:,:,3) = img(:,:);

img=imread('cthulhu2.jpg');
img = imresize(img,[320 240]);
img = sum(img,3);
img = img / max(img(:));

uimg(:,:,4) = img(:,:);

img=imread('ork.jpg');
img = imresize(img,[320 240]);
img = sum(img,3);
img = img / max(img(:));

uimg(:,:,5) = img(:,:);

img=imread('sandman.jpg');
img = imresize(img,[320 240]);
img = sum(img,3);
img = img / max(img(:));

uimg(:,:,6) = img(:,:);

img=imread('ton1.jpg');
img = imresize(img,[320 240]);
img = sum(img,3);
img = img / max(img(:));

uimg(:,:,7) = img(:,:);

img=imread('ton2.jpg');
img = imresize(img,[320 240]);
img = sum(img,3);
img = img / max(img(:));

uimg(:,:,8) = img(:,:);

figure;

for i=1:8
    [im1, im2] = query(uimg(:,:,i), pic);
    
    subplot(3,8,i), imshow(uimg(:,:,i))
    subplot(3,8,i+8), imshow(im1)
    subplot(3,8,i+16), imshow(im2)
end
