[][src]Module opencv::img_hash

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).

Introduction to image hash module of opencv Speed up image hashing of opencv(img_hash) and introduce color moment hash

Contributors

Tham Ngap Wei, thamngapwei@gmail.com

Structs

AverageHash

Computes average hash value of the input image

BlockMeanHash

Image hash based on block mean.

ColorMomentHash

Image hash based on color moments.

ImgHashBase

The base class for image hash algorithms

MarrHildrethHash

Marr-Hildreth Operator Based Hash, slowest but more discriminative.

PHash

pHash

RadialVarianceHash

Image hash based on Radon transform.

Constants

BLOCK_MEAN_HASH_MODE_0

use fewer block and generate 16*16/8 uchar hash value

BLOCK_MEAN_HASH_MODE_1

use block blocks(step sizes/2), generate 31*31/8 + 1 uchar hash value

Traits

ImgHashBaseTrait

The base class for image hash algorithms