MATLAB: Histogram method

histogramimage processing

hello,i have filtered out images from the database based on global descriptor attributes and now i have to use histogram method on these filtered out images and find out the image which matches exactly with the query image.i have used the following steps:
l=0:16:255;
x_i=imread('peppers.png');
x=double(x_i);
r=x(:,:,1);
n1=histc(r,l);
c_elements1=cumsum(n1);
element1=length(c_elements1)

Best Answer

You could just subtract the histograms and find out which pair gives all zeros. This would work if you knew for a fact in advance that your image was definitely in the first batch of candidate images you pulled out of the database. Be aware though that it's possible, though not very likely, that two different images could have the same histograms. However if you have 256 bins, it's unlikely that each and every one of the 256 bins will have exactly the same count level in it, so it should work pretty well (again assuming your image is definitely in there). Something like
noDifference = sum(hist1-hist2) == 0;