Crates.io | pdqhash |
lib.rs | pdqhash |
version | 0.1.1 |
source | src |
created_at | 2022-07-08 04:02:33.156852 |
updated_at | 2022-07-08 04:42:17.242582 |
description | Perceptual Hashing, originally designed by Facebook. Identify the same image even after some modifications. |
homepage | |
repository | https://github.com/darwinium-com/pdqhash |
max_upload_size | |
id | 621614 |
size | 4,287,161 |
This hash is a pure Rust implementation of the PDQ algorithm described here.
The PDQ algorithm was developed and open-sourced by Facebook (now Meta) in 2019. It specifies a transformation which converts images into a binary format ('PDQ Hash') whereby 'perceptually similar’ images produce similar outputs. It was designed to offer an industry standard for representing images to collaborate on threat mitigation.
Comparing two images reduces to computing distance (for example, Hamming distance) between their representations, or as % bit similarity.
(16 bits are just used here for easier interpretation; PDQ hashes represent 256 bits)
Additionally, PDQ hashes for rotations and mirrors of the original image can be inferred efficiently, by just manipulating the Discrete Cosine Transform created in latter stages of processing. Example: PDQ Hash of mirrored original image only requires manipulation of the transform
DCT Manipulation needed for corresponding PDQ Hash
The resulting hashes are resilient to certain transformations, some more so than others, to detect additional attempted manipulation. Generally, images retaining overall structure are more resilient than changes to pixel positions and larger areas of pixel change.
Transformations that result in similar hashes: