Histogram method

7 views (last 30 days)
Padma
Padma on 6 Oct 2011
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)
  2 Comments
UJJWAL
UJJWAL on 6 Oct 2011
What is ur exact question. Please be precise so that we can help better.
UJJWAL
Padma
Padma on 6 Oct 2011
i have a few images and i have to perform histogram on them to find out which image perfectly matches with the query image.so how do i go about it?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 6 Oct 2011
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;
  3 Comments
Image Analyst
Image Analyst on 7 Oct 2011
If all you want to do is to detect an exact match, it's not necessary to normalize by the number of pixels, or to square the differences. But if the images are of different sizes, or somehow slightly different (e.g. slightly cropped or edited somehow) then that is a good idea. The error in that case should be small but not necessarily exactly zero.
Padma
Padma on 8 Oct 2011
ya,all images are of different sizes.so this method has worked pretty fine.i got zero error for two similar images.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 6 Oct 2011
Are the histograms all exactly the same length? Do they each encompass the same number of values, or does the height of the histogram need to be scaled to reflect different number of sample points? If two histograms are identical except that one sample moved from one bin to the adjacent bin (perhaps due to round-off error), then should those be considered matches or not?
Is the question really about the histograms themselves, or are you interested in the probability that the histogram from one is drawn from the same statistical distribution as the histogram from the other?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!