Skip to content

Commit

Permalink
Major update. Prepare for maven release
Browse files Browse the repository at this point in the history
  • Loading branch information
KilianB committed Aug 3, 2018
1 parent 456353d commit edd7d09
Show file tree
Hide file tree
Showing 38 changed files with 2,806 additions and 379 deletions.
30 changes: 30 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_60"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 1,3 @@
.DS_Store
/bin/
/target/
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>JImageHash</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
14 changes: 14 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
21 changes: 21 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 1,21 @@
- Semantic versioning

## [0.1.0] - 3.8.2018
## Added
- BinaryTree class to save & compare precomputed hashes
- UnitTests for hash algorthms and basic matchers
- Examples
- Extensive gui example
- Algorithm identifiers preventing mismatching hashes to be compared

## Changed
- Preparation for maven distribution. Changed package structure
- Using a dedicated Hash class instead of a BigInteger to represent hash results




## [0.0.8] -
## Added
- MIT License
- usage of changelog
41 changes: 17 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 96,24 @@ Each algorithm comes with individual properties


````java
//Approximate final hash resolution
int bitResolution = 64;

public static void main(String[] args){

//Load images
BufferedImage img1 = ImageIO.read(new File("image1.jpg"));
BufferedImage img2 = ImageIO.read(new File("image2.jpg"));

//Pick an algorithm
HashingAlgorithm hasher = new AverageHash(bitResolution);

//Calculate similarity score
double normDistance = ImageHash.normalizedHammingDistance(hasher.hash(img1),hasher.hash(img2));
double distance = ImageHash.hammingDistance(hasher.hash(img1),hasher.hash(img2));

if(normDistance < 0.1){
//Duplicate found. Most likely an altered image
}

//Or
if(distance < 10){
//Likely duplicate found
}
}
//Key bit resolution
int keyLength = 64;

//Pick an algorithm
HashingAlgorithm hasher = new AverageHash(keyLength);

public boolean compareTwoImages(File image1, File image2) throws IOException {

//Hash images
Hash hash1 = hasher.hash(image1);
Hash hash2 = hasher.hash(image2);

//Ranges between 0 - keyLength. The lower the more similar the image is.
int similarityScore = hash1.hammingDistance(hash2);

return similarityScore < 20;
}

````
Only hashes produced by the same algorithm with the same bit resolution can be compared.
Expand Down
Binary file removed lib/JTransforms-3.1-with-dependencies.jar
Binary file not shown.
90 changes: 90 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 1,90 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


<!-- Project settings -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.kilianB</groupId>
<artifactId>JImageHash</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
<bintrayRepository>maven</bintrayRepository>
<bintrayPackage>JImageHash</bintrayPackage>
</properties>

<licenses>
<license>
<name>MIT</name>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<name>Kilian Brachtendorf</name>
<email>[email protected]</email>
<roles>
<role>developer</role>
</roles>
<timezone>Europe/Berlin</timezone>
</developer>
</developers>



<!-- Dependencies -->

<dependencies>
<dependency>
<groupId>com.github.wendykierp</groupId>
<artifactId>JTransforms</artifactId>
<version>3.1</version>
<classifier>with-dependencies</classifier>
</dependency>

<!-- Google image downloading dependency -->
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.32</version>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180725.0427</version>
</dependency>

<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>8.0.4</version>
</dependency>
</dependencies>

<!-- Build settings -->
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<release>10</release>
</configuration>
</plugin>
</plugins>
</build>

<!-- Environment Settings -->
<distributionManagement>
<repository>
<id>bintrayServer</id>
<url>https://bintray.com/kilianb/${bintrayRepository}/${bintrayPackage}/${project.version};publish=1</url>
</repository>
</distributionManagement>


</project>
93 changes: 0 additions & 93 deletions src/hashAlgorithms/PerceptiveHash.java

This file was deleted.

Loading

0 comments on commit edd7d09

Please sign in to comment.