dataeval.core.dhash_d4

dataeval.core.dhash_d4(image)

Compute orientation-invariant difference hash using gradients.

Computes dhash for all 8 dihedral group transformations (4 rotations × 2 flip states) and returns the lexicographically smallest hash as the canonical representative.

Parameters:
image : Array3D

An image in CxHxW format. Can be a 3D list, or array-like object.

Returns:

Canonical hex string hash invariant to rotation and mirroring, or empty string if image is too small or not spatial data.

Return type:

str

See also

dhash

Standard orientation-sensitive difference hash

phash_d4

Orientation-invariant perceptual hash

Notes

This hash is invariant to: - 90°, 180°, 270° rotations - Horizontal and vertical flips - Any combination of rotation and flip

The canonical hash is the lexicographically smallest hash among all 8 orientations, ensuring that any orientation of the same image produces the identical hash.

Computation cost is ~8x that of regular dhash.