dataeval.core.phash¶
- dataeval.core.phash(image)¶
Compute perceptual hash using Discrete Cosine Transform (DCT).
Resizes image to a square NxN using Lanczos algorithm where N is 32x32 or the largest multiple of 8 smaller than input dimensions. The resampled image is compressed using DCT and the lowest frequency component is encoded as a bit array of greater or less than median value.
- Parameters:¶
- image : Array3D¶
An image in CxHxW format. Can be a 3D list, or array-like object.
- Returns:¶
Hex string hash of the image, or empty string if image is too small or not spatial data.
- Return type:¶
str
Notes
DCT-based hashing (pHash) is robust to: - Scaling and resizing - Minor color adjustments - Compression artifacts
It captures frequency information, making it effective for detecting images that have been resized or slightly modified.