As I don't know the limit of histogram comparison ,I decided to ask the wonderful community.
I have some images and I want to group them according to its similarity.every image has a unique colored lines starting from the top down to the bottom of the image,so what I did is taking a vertical projection through those colored lines and make a histogram for this projection for every image.It works well as two similar images should have two similar histogram (i.e both go up and down almost exactly the same rounds) as a human I can decide that both histograms are similar according to that uniquely feature even if one histogram doesn't have high values of its peaks (i.e that is a histogram of a faint image)
The images with its corresponding histograms:
....................1st http://imageshack.us/a/img571/948/onelg.jpg..................................................2nd http://imageshack.us/a/img255/642/twor.jpg........................................ 3rd http://imageshack.us/a/img577/3931/threeaw.jpg................
1sth http://imageshack.us/a/img823/4343/onehq.png 2ndh http://imageshack.us/a/img687/3738/twoht.png 3rdh http://imageshack.us/a/img43/9996/threeh.png
.........................................................................2nddarker http://imageshack.us/a/img690/7817/twodark.jpg
.................................................2nddarkhist http://img20.imageshack.us/img20/6070/darkerh.png
I converted the two images to gray-scale , then I made a vertical projection of the image converting it to a histogram and As you may notice the first two histograms are similar but the third is kinda different that's because it has a switched colored lines.
Note:-
(1) considering the first two histograms .Although the highest beak is nearly 12, it isn't always the case with some images are darker or fainter but in the end it really gives the same morphology of the histogram if I can say that as you can notice the last histogram is of a darker image of the second one.
My question is :Is it safe to do any kind of histogram comparison??Does histogram comparison mean that I can decide if two histograms have the same peaks for example? or may be in others words does histogram comparison tell me if two histograms have the same morphology??What is the best library or method to do this kind of comparison in python
??
Update:-
(1) As a reply @PepperoniPizza and @FedericoCristina ,In my case totally different images will surely have different histograms (you can rely on that) every image has a unique histogram morphology(i.e unique peaks) and the number of peaks varies from one image to another but two similar image should have the same number of peaks (in other words> if you look at their histogram, you can tell they kinda look like the same( lookat the 1st,2nd and the last histogram to see what I mean.
(2) To be clear about this I really don't want a solution of how I can group my images but I'm paying a lot of intention of how I can decide that two histograms have similar shape or morphology as a general case!!!!
(3) I know about cv2.CompareHist()
but I don't know if it is a proper method to compare my histograms as I don't know how cv2.CompareHist()
works(i.e I don't know on what base they do comparison) and actually cv2.CompareHist()
has 4 types of histogram comparison which I don't know what is the best or even what is the alternative method to do such comparison.
(4) as a reply @remi,here is the point:-I had already 3 libraries in which they support histogram comparison,and it's kinda ambiguous -for me at least- to know what they meant by histogram comparison as some just do like h1-h2
and then calcuate(MSE)
so all it does is comparing values not the shape these values form in the histogram.So as I'm not that good at histograms and their math-work, I'm wondering if I really can compare histograms such a way.
Thanks