Module opencv::img_hash

source ·
Expand description

The module brings implementations of different image hashing algorithms.

Provide algorithms to extract the hash of images and fast way to figure out most similar images in huge data set.

Namespace for all functions is cv::img_hash.

Supported Algorithms

  • Average hash (also called Different hash)
  • PHash (also called Perceptual hash)
  • Marr Hildreth Hash
  • Radial Variance Hash
  • Block Mean Hash (modes 0 and 1)
  • Color Moment Hash (this is the one and only hash algorithm resist to rotation attack(-90~90 degree))

You can study more about image hashing from following paper and websites:

Code Example

@include samples/hash_samples.cpp

Performance under different attacks

Performance chart

Speed comparison with PHash library (100 images from ukbench)

Hash Computation chart Hash comparison chart

As you can see, hash computation speed of img_hash module outperform PHash library a lot.

PS : I do not list out the comparison of Average hash, PHash and Color Moment hash, because I cannot find them in PHash.

Motivation

Collects useful image hash algorithms into opencv, so we do not need to rewrite them by ourselves again and again or rely on another 3rd party library(ex : PHash library). BOVW or correlation matching are good and robust, but they are very slow compare with image hash, if you need to deal with large scale CBIR(content based image retrieval) problem, image hash is a more reasonable solution.

More info

You can learn more about img_hash modules from following links, these links show you how to find similar image from ukbench dataset, provide thorough benchmark of different attacks(contrast, blur, noise(gaussion,pepper and salt), jpeg compression, watermark, resize).

Contributors

Tham Ngap Wei, thamngapwei@gmail.com

Modules

Structs

Enums

Constants

Traits

Functions

  • Calculates img_hash::AverageHash in one call
  • Computes block mean hash of the input image
  • Computes color moment hash of the input, the algorithm is come from the paper “Perceptual Hashing for Color Images Using Invariant Moments”
  • Computes average hash value of the input image
  • Computes pHash value of the input image
  • Computes radial variance hash of the input image