Overview
CLD (Color Layout Descriptor) is an MPEG-7 standard perceptual hash algorithm that captures the spatial distribution of colors in an image. It provides a compact 12-element descriptor that is effective for color-based image similarity.How It Works
The CLD algorithm processes images through the following steps:- Color space conversion: The image is converted to YCbCr color space
- Layout summarization: The image is divided into an 8×8 grid, with average color values computed for each cell
- DCT transformation: A 2-D Discrete Cosine Transform (DCT) is applied to each color channel
- Coefficient selection: Low-frequency zig-zag DCT coefficients are extracted:
- 6 Y (luminance) coefficients
- 3 Cb (blue chrominance) coefficients
- 3 Cr (red chrominance) coefficients
- Quantization: Coefficients are quantized into a compact 12-element UInt8 descriptor
CLD returns a UInt8 hash type (12 bytes), not Binary or Float64.
When to Use CLD
CLD is particularly effective for:- Color-based image retrieval
- Images with distinct color layouts
- Applications requiring compact color descriptors
- Thumbnail or icon matching
- Images where spatial color distribution is important
- Grayscale images (though it will still work)
- Images where fine texture details are more important than color
Constructor
Options
Sets the resize dimensions before hash computation. The image is resized to this size before processing.Default: 64×64 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.L2 (Euclidean distance)Available functions: Hamming, L1, L2, Cosine, ChiSquare, PCC, JaccardUsage Example
Default Settings
| Parameter | Default Value |
|---|---|
| Width | 64 pixels |
| Height | 64 pixels |
| Interpolation | Bilinear |
| Distance Function | L2 (Euclidean) |
| Hash Length | 12 bytes |
Technical Details
- Hash Type:
hashtype.UInt8 - Hash Length: 12 bytes (6 Y + 3 Cb + 3 Cr coefficients)
- Default Comparison: L2 (Euclidean) distance
- Color Space: YCbCr
- Grid Size: 8×8
- DC Quantization Range: 0-63 (6 bits)
- AC Quantization Range: 0-31 (5 bits, centered at 16)
References
- MPEG-7 Color Layout Descriptor standard
- Based on DCT transformation and zig-zag coefficient ordering