Histogram method
7 views (last 30 days)
Show older comments
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
on 6 Oct 2011
What is ur exact question. Please be precise so that we can help better.
UJJWAL
Accepted Answer
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
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.
More Answers (1)
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?
0 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!