Feed the following method with your histograms and keep track of which generated the lowest distance value. That one should be the closest match.

public static int calculateDistance(Histogram histo1, Histogram histo2) {

int distance = 0;

for (int b = 0; b < 3; b++) {

for (int j = 0; j < 256; j++) { // for RGB 256*3

int d = histo1.getFrequency(b, j) - histo2.getFrequency(b, j);

distance += Math.abs(d);

}

}

return distance;

}

public static int calculateDistance(Histogra

int distance = 0;

for (int b = 0; b < 3; b++) {

for (int j = 0; j < 256; j++) { // for RGB 256*3

int d = histo1.getFrequency(b, j) - histo2.getFrequency(b, j);

distance += Math.abs(d);

}

}

return distance;

}