imgdb = cell(1,8);

imgdbnames = {'class1a.jpg','class1b.jpg','class2a.jpg','class2b.jpg','class3a.jpg','class3b.jpg','class4a.jpg','class4b.jpg'};

for i=1:8
    imgdb{i} = imread(imgdbnames{i});
end

for i=1:8
    [im1, im2] = query(imgdb{i},imgdb);
    subplot(3,8,i); image(imgdb{i}); colormap(gray(256)); axis off;
    subplot(3,8,i+8); image(imgdb{im1}); colormap(gray(256)); axis off;
    subplot(3,8,i+16); image(imgdb{im2}); colormap(gray(256)); axis off;
end
