%Reading 8 images in four classes,where 2 images in each class are similar.

global V;
rgb_img1 = imread('image1.jpg');
I11 = rgb2gray(rgb_img1);
V11=imhist(I11);

rgb_img2 = imread('image2.jpg');
I12 = rgb2gray(rgb_img2);
V12=imhist(I12);

% VT1=V11-V12;
% fprintf('norm1\n');
% N1=norm(VT1,inf);
% fprintf('norm1 %d \n',N1);

rgb_img3 = imread('image3.jpg');
I21 = rgb2gray(rgb_img3);
V21=imhist(I21);

rgb_img4 = imread('image4.jpg');
I22 = rgb2gray(rgb_img4);
V22=imhist(I22);

% VT2=V21-V22;
% fprintf('norm2\n');
% N2=norm(VT2,inf);
% fprintf('norm2%d \n',N2);

rgb_img5 = imread('image5.jpg');
I31 = rgb2gray(rgb_img5);
V31=imhist(I31);

rgb_img6 = imread('image6.jpg');
I32 = rgb2gray(rgb_img6);
V32=imhist(I32);

% VT3=V31-V32;
% fprintf('norm3\n');
% N3=norm(VT3,inf);
% fprintf('norm3%d \n',N3);

rgb_img7 = imread('image7.jpg');
I41 = rgb2gray(rgb_img7);
V41=imhist(I41);

rgb_img8 = imread('image8.jpg');
I42 = rgb2gray(rgb_img8);
V42=imhist(I42);

% VT4=V41-V42;
% fprintf('norm4\n');
% N4=norm(VT4,inf);
% fprintf('norm4%d\n', N4);

% V contains all the vectors of image histograms.

 V=[V11,V12,V21,V22,V31,V32,V41,V42];
for i=1:8

 im = strcat('image',int2str(i),'.jpg');
 [im1,im2] = query(im);


 ig=imread(im);
 a=imread(im1);
 b=imread(im2);
 
 ad=im2double(a);
 bd=im2double(b);
 id=im2double(ig);
 
 % subplotting the images in the required format.
 
 subplot(3,8,i);imshow(id);
 subplot(3,8,i+8);imshow(ad);
 subplot(3,8,i+16);imshow(bd);

 % %N(i,1)=normal;
end