Git Product home page Git Product logo

jphash's Introduction

About jpHash

This is library based on the great work behind pHash, the perceptual hash library (http://www.phash.org/).

My main problem with using this library is that it is written in C++ and I'm a Java guy. So I decided to have a go at converting it to Java.

Currently, only the Radial Image hash algorithm is implemented as that's the only one I've needed yet, but implementing the rest of the image hashing algorithms should be trivial as they are all based on the same preprocessing of the image (grayscaling, correcting brightness, blurring and scaling)... and all that is done already.

Efficiency

I've invested quite a bit in making this efficient. Some personal benchmarks have given me execution times comparable to the C++ version. Of course that meant that I had to implement my own grayscaling, resizing and bluring algorithms.

Licence

I still need to add all the licencing info, but the idea is that it be LGPL so it can be included in other distributed work. I'm still checking, but I believe this is compatible with the GPL version that pHash is on.

Usage

Simple:

RadialImageHash hash1 = jpHash.getImageRadialHash("/path/to/image");
System.out.println("Hash1: " + hash1);
RadialImageHash hash2 = jpHash.getImageRadialHash("/path/to/other/image");
System.out.println("Hash2: " + hash2);

System.out.println("Similarity: " + jpHash.getSimilarity(hash1, hash2));

You can also persist the string representation of the hash and recover it with: RadialHash.fromString(String)

Links

Some links of interest that this work is based upon:

For info on building an efficient index for Nearest neighbour search (my planned next stage). These are some of the papers I've found:

jphash's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jphash's Issues

Non-deterministic behavior of SimpleGrayscaleImage.blur() due to JIT in OpenJDK 14.0.1

Today we found out that there seems to be a bug in the JIT implementation of OpenJDK 14.0.1 that makes the behavior of at least one method - SimpleGrayscaleImage.blur() - non-deterministic.

You can test and verify this by running the JUnit tests of this project with using OpenJDK 14.0.1 and the following tests "flicker", i.e. sometimes pass, but often don't pass. If you run all tests in RadialHashAlgorithmTest, then testHashEarth2 and testHashSerialization will flicker. If you run each of those test methods isolated by itself, it will succeed.

Also, the hash is not stable:

Exp :a3ff195b0048ac9be693c3a394a1bcb7ab9bb5b4baababa8c0a4b19daa9eb2a7aba2aea7af97ada3
Run1:a5ff1c5b0049ae9de895c5a596a3bdb8ad9db8b6bcadaea9c2a6b39faca0b4a9ada3b0a9b199afa5
Run5:a5fe1b5b0049ae9de895c5a596a3bdb8ad9db8b6bcadaea9c2a6b39eaca0b4a9ada3b0a9b199afa5

Both tests will pass consistently if the following VM parameters are passed when testing:

-XX:CompileCommand=exclude,com/pragone/jphash/image/SimpleGrayscaleImage,blur

Alternatively, you can use OpenJDK 13.

(Other JUnit tests fail, too, but they also fail with OpenJDK 13, so that is probably not related to JIT.)

We'll probably submit a bug report to OpenJDK soon.

Problem with RadialImageHash

Hi, I have a problem with using this library,

I have imported the library in the main class of my project, but NetBeans says "Cannot find symbol class: RadialImageHash, location: class Comparador (my main package's name)" I attached a cap of the view.
Im new in Java, so i dont know if its okay to put te folder of this library on the folder src/main/ of my project, because i did it, and... doesnt work.
cap:
https://drive.google.com/file/d/0B_UpjJQna4J4d0pJSkhZUUhWbVU/view?usp=sharing

Thanksss!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.