% task1

im{1}=imread('a1.jpg');
im{2}=imread('a2.jpg');
im{3}=imread('a3.jpg');
im{4}=imread('a4.jpg');

for i=1:4
   im{i}=rgb2gray(im{i})';
end;

im{5}=im{1}-10;
im{6}=im{2}+10;
im{7}=im{3}*0.8;
im{8}=im{4}-4;


for i=1:8
   img=im{i};   
   subplot(3,8,i);
   imshow(img);
   [im1,im2]=query(img, im);   
   subplot(3,8,i+8);
   imshow(im1);   
   subplot(3,8,i+16);
   imshow(im2);
end


