Enum img_hash::HashAlg[][src]

pub enum HashAlg {
    Mean,
    Gradient,
    VertGradient,
    DoubleGradient,
    Blockhash,
    // some variants omitted
}

Hash algorithms implemented by this crate.

Implemented primarily based on the high-level descriptions on the blog Hacker Factor written by Dr. Neal Krawetz: http://www.hackerfactor.com/

Note that hash_width and hash_height in these docs refer to the parameters of HasherConfig::hash_size().

Choosing an Algorithm

Each algorithm has different performance characteristics

Variants

Mean

The Mean hashing algorithm.

The image is converted to grayscale, scaled down to hash_width x hash_height, the mean pixel value is taken, and then the hash bits are generated by comparing the pixels of the descaled image to the mean.

This is the most basic hash algorithm supported, resistant only to changes in resolution, aspect ratio, and overall brightness.

Further Reading: http://www.hackerfactor.com/blog/?/archives/432-Looks-Like-It.html

Gradient

The Gradient hashing algorithm.

The image is converted to grayscale, scaled down to (hash_width + 1) x hash_height, and then in row-major order the pixels are compared with each other, setting bits in the hash for each comparison. The extra pixel is needed to have hash_width comparisons per row.

This hash algorithm is as fast or faster than Mean (because it only traverses the hash data once) and is more resistant to changes than Mean.

Further Reading: http://www.hackerfactor.com/blog/index.php?/archives/529-Kind-of-Like-That.html

VertGradient

The Vertical-Gradient hashing algorithm.

Equivalent to Gradient but operating on the columns of the image instead of the rows.

DoubleGradient

The Double-Gradient hashing algorithm.

An advanced version of Gradient; resizes the grayscaled image to (width / 2 + 1) x (height / 2 + 1) and compares columns in addition to rows.

This algorithm is slightly slower than Gradient (resizing the image dwarfs the hash time in most cases) but the extra comparison direction may improve results (though you might want to consider increasing hash_size to accommodate the extra comparisons).

Blockhash

The Blockhash.io algorithm.

Compared to the other algorithms, this does not require any preprocessing steps and so may be significantly faster at the cost of some resilience.

The algorithm is described in a high level here: https://github.com/commonsmachinery/blockhash-rfc/blob/master/main.md

Trait Implementations

impl Clone for HashAlg[src]

impl Copy for HashAlg[src]

impl Debug for HashAlg[src]

impl<'de> Deserialize<'de> for HashAlg[src]

impl Eq for HashAlg[src]

impl PartialEq<HashAlg> for HashAlg[src]

impl Serialize for HashAlg[src]

impl StructuralEq for HashAlg[src]

impl StructuralPartialEq for HashAlg[src]

Auto Trait Implementations

impl RefUnwindSafe for HashAlg

impl Send for HashAlg

impl Sync for HashAlg

impl Unpin for HashAlg

impl UnwindSafe for HashAlg

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.