Overview
EHD (Edge Histogram Descriptor) is an MPEG-7 standard perceptual hash algorithm that captures the spatial distribution of edges in an image. It describes edge orientations across different regions of the image, making it effective for texture and shape-based similarity.How It Works
The EHD algorithm processes images through the following steps:- Preprocessing: The image is resized and converted to grayscale
- Grid division: The image is divided into a 4×4 grid of cells
- Local edge detection: For each cell, 2×2 pixel blocks are analyzed for edge patterns
- Edge classification: Each edge is classified into one of 5 types:
- Vertical
- Horizontal
- 45° diagonal
- 135° diagonal
- Non-directional
- Histogram computation: A 5-bin histogram is built for each grid cell
- Quantization: Each histogram bin is quantized to 3 bits using MPEG-7 quantization tables
EHD returns a UInt8 hash type (80 bytes), not Binary or Float64.
When to Use EHD
EHD is particularly effective for:- Texture-based image retrieval
- Shape and structure matching
- Images with strong edge patterns
- Object recognition based on contours
- Document or logo matching
- Images with very subtle textures
- Smooth gradients without clear edges
- Color-based matching (uses grayscale only)
Constructor
Options
Sets the resize dimensions before hash computation. The image is resized to this size before processing.Default: 256×256 pixels
Sets the interpolation method used when resizing the image.Default:
BilinearAvailable options: NearestNeighbor, Bilinear, Bicubic, LanczosOverrides the default distance function used by the
Compare method.Default: similarity.L1 (Manhattan distance)Available functions: Hamming, L1, L2, Cosine, ChiSquare, PCC, JaccardUsage Example
Default Settings
| Parameter | Default Value |
|---|---|
| Width | 256 pixels |
| Height | 256 pixels |
| Interpolation | Bilinear |
| Distance Function | L1 (Manhattan) |
| Hash Length | 80 bytes |
| Grid Size | 4×4 |
| Edge Types | 5 |
Technical Details
- Hash Type:
hashtype.UInt8 - Hash Length: 80 bytes (4×4 grid cells × 5 edge types)
- Default Comparison: L1 (Manhattan) distance
- Color Processing: Converted to grayscale
- Edge Threshold: 11.0
- Quantization: 3 bits per bin (8 levels) using MPEG-7 tables
- Block Size: 2×2 pixels for edge detection
Edge Types
The five edge types detected by EHD:- Vertical: Edges running vertically
- Horizontal: Edges running horizontally
- 45° Diagonal: Edges from bottom-left to top-right
- 135° Diagonal: Edges from top-left to bottom-right
- Non-directional: Edges without clear orientation
References
- MPEG-7 Edge Histogram Descriptor standard
- Uses standardized quantization tables for 3-bit histogram encoding