A general purpose framework for finding near-duplicate images, which provides an image library for fast pixel comparisons, along with extensible implementations and tools for image hashing and attacking image hashes, including simulating jpg/jpeg compression.
Greyscale ✓
RGB (Red, Green, Blue) ✓
RGBA (RGB with alpha/transparency channel) ✓
YCbCr (Luminance, Chrominance toward blue, Chrominance toward red) ✓
CMYK (Cyan, Magenta, Yellow, Black)
HSI (Hue, Saturation, Intensity. A cartesian transformation of RGB colorspace)
All examples will use Lena:
Inspiration: Hacker Factor
Pros: Very fast
Cons: Not extremely accurate
Description:
Inspiration: Hacker Factor
Pros: A good general hash. Almost as fast as aHash, and doesn't care much about changes of background.
Cons: Not robust against flips/rotations
Description:
- Resize to 9x8
- Reduce to Greyscale
- Set the bits of the hash row by row, depending on if the pixel to the left is less than the pixel to the right. If it is, set it to 1. If not, set to 0. This results in an 8x8, laid out into a 64 bit hash.
Inspiration: Hacker Factor PHash.org
Pros:
Cons: Slow
Description:
Inspiration: "Image Hashing Based on Color Histogram" by Bian Yang, Fan Gu and Xiamu Niu
Pros: Invariant to flips and rotations
Cons:
Description:
Inspiration: "Image Hashing Based on Color Histogram" by Bian Yang, Fan Gu and Xiamu Niu
Pros:
Cons:
Description: I figured that if an RGB histogram could be used to match images, then a Greyscale Implementation would also be useful for Greyscale Images.
Inspiration: Shower thoughts
Pros: Faster than pHash, resulting hash is extremely small
Cons: As a result of such a small hash, collisions are more common. Best used in together with other algorithms like pHash.
Description:
Inspiration: "Block Mean Value Based Image Perceptual Hashing by Bian Yang, Fan Gu and Xiamu Niu"
Pros:
Cons:
Description:
JPEG Compression Simulation
Flip Vertical L/R
Random Noise
Gaussian Noise ✓
Subimage Insertion
Create and match two hashes:
IHashAlgorithm h = HashFactory.AVERAGE_HASH;
ImageHash hash1 = HashFactory.hash(img1, h);
ImageHash hash2 = HashFactory.hash(img2, h);
boolean matchesNormal = h.matches(img1, img2);
boolean matchesStrict = h.matches(img1, img2, MatchMode.STRICT);