Struct img_hash::ImageHash [] [src]

pub struct ImageHash {
    pub bitv: BitVec,
    pub hash_type: HashType,
}

A struct representing an image processed by a perceptual hash. For efficiency, does not retain a copy of the image data after hashing.

Get an instance with ImageHash::hash().

Fields

The bits of the hash

The type of the hash

Methods

impl ImageHash
[src]

Create a hash of img with a length of hash_size * hash_size (* 2 when using HashType::DoubleGradient) using the hash algorithm described by hash_type.

Calculate the Hamming distance between this and other. Equivalent to counting the 1-bits of the XOR of the two BitVec.

Essential to determining the perceived difference between self and other.

Panics

If self and other have differing bitv lengths or hash_type values.

Calculate the Hamming distance between self and other, then normalize it to [0, 1], as a fraction of the total bits.

Roughly equivalent to the % difference between the two images, represented as a decimal.

See ImageHash::dist().

Get the hash size of this image. Should be equal to the number of bits in the hash.

Get the HashType that this ImageHash was created with.

Build a grayscale image using the bits of the hash, setting pixels to white (0xff) for 0 and black (0x00) for 1.

Create an ImageHash instance from the given Base64-encoded string.

Note:

Not compatible with Base64-encoded strings created before HashType was added.

Does not preserve the internal value of HashType::UserDCT.

Errors:

Returns a FromBase64Error::InvalidBase64Length when trying to hash a zero-length string

Get a Base64 string representing the bits of this hash.

Mostly for printing convenience.

Trait Implementations

impl PartialEq for ImageHash
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for ImageHash
[src]

impl Hash for ImageHash
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for ImageHash
[src]

Formats the value using the given formatter.

impl Clone for ImageHash
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more