Overview
RadialVariance is a perceptual hash algorithm that uses radial projection analysis to create rotation-aware image descriptors. It computes the variance of pixel values along radial lines at different angles, making it effective for images that may be rotated.How It Works
The RadialVariance algorithm processes images through the following steps:- Preprocessing: The image is converted to grayscale
- Gaussian blur: A Gaussian blur is applied with specified sigma to reduce noise
- Radial projections: Pixel values are projected along lines at different angles through the image center
- Variance computation: For each angle, compute the variance of projected pixel values
- Normalization: Feature vector is normalized (mean subtraction and variance scaling)
- DCT transformation: Discrete Cosine Transform is applied to the feature vector
- Quantization: DCT coefficients are quantized to a 40-element UInt8 descriptor
RadialVariance returns a UInt8 hash type (40 bytes), not Binary or Float64.
When to Use RadialVariance
RadialVariance is particularly effective for:- Images that may be rotated
- Circular or radially symmetric objects
- Logo matching with orientation variations
- Images where rotation invariance is important
- Robust matching under geometric transformations
- Images requiring color information (uses grayscale only)
- Very small images
- Images where exact orientation matters
Constructor
Options
Sets the Gaussian kernel standard deviation for blur preprocessing.Default: 1.0Higher values create more blur, reducing noise but potentially losing detail.
Sets the number of projection angles to consider.Default: 180More angles provide finer angular resolution but increase computation time.
Overrides the default distance function used by the
Compare method.Default: similarity.L1 (Manhattan distance)Available functions: Hamming, L1, L2, Cosine, ChiSquare, PCC, JaccardUnlike most algorithms, RadialVariance does not support
WithSize or WithInterpolation options. It processes images at their original dimensions.Usage Example
Default Settings
| Parameter | Default Value |
|---|---|
| Sigma | 1.0 |
| Angles | 180 |
| Distance Function | L1 (Manhattan) |
| Hash Length | 40 bytes |
Technical Details
- Hash Type:
hashtype.UInt8 - Hash Length: 40 bytes (fixed)
- Default Comparison: L1 (Manhattan) distance
- Color Processing: Converted to grayscale
- Blur Method: Gaussian blur with configurable sigma
- Projection Method: Radial lines from image center
- Feature Extraction: Variance along each radial projection
- Transform: DCT (Discrete Cosine Transform)
- Normalization: Mean-variance normalization of features
Configuration Guidelines
Sigma Values
| Sigma | Blur Amount | Use Case |
|---|---|---|
| 0.5 | Minimal | Clean, high-quality images |
| 1.0 | Default | General purpose |
| 1.5-2.0 | Moderate | Noisy images |
| > 2.0 | Heavy | Very noisy or low-quality images |
Angle Count
| Angles | Angular Resolution | Trade-off |
|---|---|---|
| 90 | 4° per angle | Faster, less precise |
| 180 | 2° per angle | Default, balanced |
| 360 | 1° per angle | Slower, more precise |
Implementation Notes
- The algorithm includes a small epsilon (0.00001) to avoid division by zero
- Handles variable image dimensions without resizing
- Projection calculations use rounding for pixel mapping
- DCT coefficients are scaled to 0-255 range for quantization
References
- De Roover, C., De Vleeschouwer, C., Lefèbvre, F., & Macq, B. (2005). “Robust image hashing based on radial variance of pixels.”
- ResearchGate