You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JImageHash is a performant perceptual image fingerprinting library entirely written in Java. The library returns a similarity score aiming to identify entities which are likely modifications of the original source while being robust various attack vectors ie. color, rotation and scale transformation.
11
11
12
-
> A perceptual hash is a fingerprint of a multimedia file derived from various features from its content. Unlike cryptographic hash functions which rely on the avalanche effect of small changes in input leading to drastic changes in the output, perceptual hashes are "close" to one another if the features are similar.
12
+
> A perceptual hash is a fingerprint of a multimedia file derived from various features from its content. Unlike cryptographic hash functions which rely on the avalanche effect of small changes in input leading to drastic changes in the output, perceptual hashes are "close" to one another if the features are similar.
13
13
14
-
This library was inspired by _Dr. Neal Krawetz_ blog post "<ahref="http://www.hackerfactor.com/blog/index.php?/archives/529-Kind-of-Like-That.html">kind of like that</a>" and incorporates several improvements. A comprehensive overview of perceptual image hashing can be found in this <ahref="https://www.phash.org/docs/pubs/thesis_zauner.pdf">paper</a> by Christoph Zauner.
14
+
This library was inspired by _Dr. Neal Krawetz_ blog post "<ahref="http://www.hackerfactor.com/blog/index.php?/archives/529-Kind-of-Like-That.html">kind of like that</a>" and incorporates several improvements. A comprehensive overview of perceptual image hashing can be found in this <ahref="https://www.phash.org/docs/pubs/thesis_zauner.pdf">paper</a> by Christoph Zauner.
15
15
16
16
## Maven
17
17
18
-
The project is hosted on maven central. __Please be aware that migrating from one major version to another usually invalidates created hashes in order to retain validity when persistently storing the hashes.__
18
+
The project is hosted on maven central. **Please be aware that migrating from one major version to another usually invalidates created hashes in order to retain validity when persistently storing the hashes.**
19
19
20
-
````XML
20
+
```XML
21
21
<dependency>
22
22
<groupId>dev.brachtendorf</groupId>
23
23
<artifactId>JImageHash</artifactId>
@@ -30,40 +30,61 @@ The project is hosted on maven central. __Please be aware that migrating from on
Examples and convenience methods can be found in the [examples repository](https://github.com/KilianB/JImageHash-Examples)
65
+
Examples and convenience methods can be found in the [examples repository](https://github.com/KilianB/JImageHash-Examples)
66
+
67
+
## Transparent image support
68
+
69
+
Support for transparent images has to be enabled specifically due to backwards compatibility and force users of the libraries to understand the implication of this setting.
70
+
71
+
The `setOpaqueHandling(Color? replacementColor, int alphaThreshold)` will replace transparent pixels with the specified color before calculating the hash.
72
+
73
+
### Be aware of the following culprits:
66
74
75
+
- the replacement color must be consistent throughout hash calculation for the entire sample space to ensure robustness against color transformations of the images.
76
+
- the replacement color should be a color that does not appear often in the input space to avoid masking out available information.
77
+
- when not specified `Orange` will be used as replacement. This choice was arbitrary and ideally, a default color should be chosen which results in 0 and 1 bits being computed in 50% of the time in respect to all other pixels and hashing algorithms.
78
+
- supplying a replacement value of null will attempt to either use black or white as a replacement color conflicting with the advice given above. Computing the contrast color will fail if the transparent area of an image covers a large space and comes with a steep performance penalty.
79
+
80
+
```java
81
+
HashingAlgorithm hasher =newPerceptiveHash(32);
82
+
83
+
//Replace all pixels with alpha values smaller than 0-255. The alpha value cutoff is taken into account after down scaling the image, therefore choose a reasonable value.
84
+
int alphaThreshold =253;
85
+
hasher.setOpaqueHandling(alphaThreshold)
86
+
87
+
```
67
88
68
89
## Multiple types image matchers are available for each situation
69
90
@@ -89,15 +110,15 @@ The `exotic` package features BloomFilter, and the SingleImageMatcher used to ma
<tr><td><ahref="https://github.com/KilianB/JImageHash/wiki/Hashing-Algorithms#averagehash-averagekernelhash-medianhash-averagecolorhash">AverageHash</a></td> <td>Average Luminosity</td> <td>Fast and good all purpose algorithm</td> </tr>
@@ -143,8 +164,7 @@ Image clustering with fuzzy hashes allowing to represent hashes with probability
0 commit comments