For doing a CBIR, I am computing the match value of two pictures. Below is my code. We can see that the input of this function is the name of two images and the output is the match value. I have the image with name "2.jpg" as my query image and I have 10 images in total with name "1.jpg" to "10.jpg". And I need to get the match values for any image among the 10 images with "2.jpg". So how can I make a loop and using the below function to get the 10 values and save them in an array? I don't want to manually change the name of the pictures in the function, and more importantly, how can I save the 10 match values in an array? Thanks in advance!
function matchfunction(C,D)
first=imread(C);
Im_red=first(:,:,1);
Im_green=first(:,:,2);
Im_blue=first(:,:,3);
hist_im1=zeros(1,256);
[h,w]=size(Im_red);
for i=1:h
for j=1:w
value_pixel1=Im_red(i,j)+1;
hist_im1(value_pixel1)=hist_im1(value_pixel1)+1;
end
end
hist_im2=zeros(1,256);
[h,w]=size(Im_green);
for i=1:h
for j=1:w
value_pixel2=Im_green(i,j)+1;
hist_im2(value_pixel2)=hist_im2(value_pixel2)+1;
end
end
hist_im3=zeros(1,256);
[h,w]=size(Im_blue);
for i=1:h
for j=1:w
value_pixel3 = Im_blue(i,j) + 1;
hist_im3(value_pixel3) = hist_im3(value_pixel3)+1;
end
end
second=imread(D);
Im_red2=second(:,:,1);
Im_green2=second(:,:,2);
Im_blue2=second(:,:,3);
hist_im4=zeros(1,256);
[h,w]=size(Im_red2);
for i=1:h
for j=1:w
value_pixel4=Im_red2(i,j) + 1;
hist_im4(value_pixel4)=hist_im4(value_pixel4)+1;
end
end
hist_im5=zeros(1,256);
[h,w]=size(Im_green2);
for i=1:h
for j=1:w
value_pixel5=Im_green2(i,j) + 1;
hist_im5(value_pixel5)=hist_im5(value_pixel5)+1;
end
end
hist_im6=zeros(1,256);
[h,w]=size(Im_blue2);
for i=1:h
for j=1:w
value_pixel6=Im_blue2(i,j) + 1;
hist_im6(value_pixel6)=hist_im6(value_pixel6)+1;
end
end
A=[hist_im1, hist_im2, hist_im3];
B=[hist_im4, hist_im5, hist_im6];
[Aa,Ab]=size(A);
for i=1:Ab
H(i)=min(A(i),B(i));
end
HI=sum(H);
HI/sum(B)