I'm working on my college project, in which I am required to do fingerprint comparison. This can be done by comparing two image and matching their pixel similarity (as per my finding).
Is there any API/library/SDK or anything available in Java, for comparing two images and getting the percentage match between them?
Check out the OpenCV library. You can find there exactly what you need. Take a look here for example of how to compare images.
Would something like this work for you. The commented lines are likely not quite right.
int numberOfPixels = 0;
float runningTotal = 0;
for (int i = 0; i < image.width; i++)
{
for (int j = 0; j < image.height; j++)
{
//Color a = image1.getPixel(i, j);
//Color b = image2.getPixel(i, j);
float differenceRed = abs(a.red() - b.red()) / 255;
float differenceGreen = abs(a.green() - b.green()) / 255;
float differenceBlue = abs(a.blue() - b.blue()) / 255;
float differenceForThisPixel = (differenceRed + differenceGreen + differenceBlue) / 3;
runningTotal += differenceForThisPixel;
numberOfPixels++;
}
}
averageDifference = (runningTotal / numberOfPixels);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With