Mubasshir Pawle
Mubasshir Pawle

Reputation: 319

Color Histogram based Image Search

I need to compare images on the basis of color histogram in java. I have Histogram of images which I did using JAI of java.

But I don't know how can i compare them using histogram.

Upvotes: 2

Views: 1611

Answers (1)

Hakan Serce
Hakan Serce

Reputation: 11256

There are different methods for measuring similarity of histgorams. One such method is Bhattacharya coefficient method.

You can use the following code for calculating this similarity measure:

float similarity = 0;
float[] targetHistogramData = ...//histogram1.getData();
float[] targetCandidateHistogramData = ...//histogram2.getData();

if( targetHistogramData.length != targetCandidateHistogramData.length){
    throw new IncompatibleHistogramsException();
}

for(int i = 0; i < targetHistogramData.length; i++){
    similarity += Math.sqrt(targetHistogramData[i]*targetCandidateHistogramData[i]);
}

return similarity;

Upvotes: 2

Related Questions