KilianB / JImageHash

Perceptual image hashing library used to match similar images
MIT License
394 stars 79 forks source link

Add rotational invariant hash #6

Open KilianB opened 5 years ago

KilianB commented 5 years ago

WIP.

Probably derived from https://www.idosi.org/mejsr/mejsr24(4)16/75.pdf

KilianB commented 5 years ago

Multiple version have been implemented and will be shipped with the next major version. The paper does not exactly outline how the hash is created and it's not fully compatible with what JImageHash is doing. Therefore an approach was adapted.

  1. Precomputation -> resize and extract Y luma component

  2. Ring parition. Rotate pixels around the center and fit it into a bucket rotationalhash

  3. Sorting the lum values of each bucket increasingly and compute a 1d dct transformation. Compute hash by comparing the values to the mean of each bucket. (Multiple bits per bucket)

3.1 (alternative) A gradient version also exists which simply compares the mean of each ring partition. With this approach we get a perfect 0 distance hash for %90 rotations but need to compute a lot of data. Slow and not worth the effort. Semantically this approach isn't clean either as an increase in ring partition index (the further out you go) means more actual pixels are represented in a single bit value.

KilianB commented 5 years ago

wip 49e0ed2158c0fdbe1715897d5dc8633eddb25d47 & b0e246e879d785017b519c1483818f08cfaa771e

KilianB commented 5 years ago

Partially resolved with #13 . Maybe look at different approaches in the future e.g. http://www.jaist.ac.jp/~kurkoski/papers/conf/Parrao-Hernandex-mwcas11.pdf