KilianB / JImageHash

Perceptual image hashing library used to match similar images
MIT License
407 stars 83 forks source link

hllo,i want to create a picture fingerprint ,how can i use you class to make it,thank you #26

Closed lxy826076 closed 5 years ago

KilianB commented 5 years ago

What exactly do you want to achieve? The fingerprint you are talking about most likely is saved in a Hash object containing the image converted to a fixed binary (01) representation.

This is a hello world example:

File img0 = new File("path/to/file.png");
File img1 = new File("path/to/secondFile.jpg");

HashingAlgorithm hasher = new PerceptiveHash(32);

Hash hash0 = hasher.hash(img0);
Hash hash1 = hasher.hash(img1);

double similarityScore = hash0.normalizedHammingDistance(hash1);

if(similarityScore < .2) {
        //Considered a duplicate in this particular case
}

Be aware this step has to be repeated with multiple algorithms to reduce false positives. The different image matchers are utility classes to help performing such a task. The example section points to a few classes explaining how to solve such a request. Please let me know if anything is unclear and we can work it out.