# DCT Perceptual Hash

> A C# image-similarity component that derives a 64-bit perceptual signature from a 64×64 DCT workspace and reduces later comparisons to XOR and Hamming distance.

- Author: Muhammet Ali Köker
- Language: en
- Canonical: https://alikoker.com.tr/en/dct-perceptual-hash-csharp
- Translation: https://alikoker.com.tr/dct-perceptual-hash-csharp
- Published: 2022-09-15T12:00:00+03:00
- Modified: 2026-08-27T10:36:29+03:00
- Verified: 2026-08-27T10:36:29+03:00
- Type: project

The useful scaling property of this implementation is that image analysis happens once per asset. A source image is mapped to a 64×64 working representation, converted to an intensity sequence and transformed with a separable DCT. The low-frequency 8×8 region is then quantized around its median, producing one `UInt64` signature.

After that preprocessing step, a collection search no longer needs another DCT for every pair. Similarity becomes a Hamming-distance operation: `popcount(hash1 XOR hash2)`. Precomputed cosine coefficients and `Vector4.Dot` in the transform path keep repeated arithmetic work bounded without changing the representation.

The resulting value is perceptual, not cryptographic. Collisions are normal, and a useful Hamming threshold has to be calibrated on the target corpus. The method also makes no general claim of invariance to large crops, rotations or perspective changes. [Variance Image Quantizer](/en/variance-image-quantizer-csharp) sits nearby in the image-processing set but solves a different problem: palette reduction and encoded PNG size.

The implementation history and design choices are documented in [Perceptual Image Similarity with DCT and SIMD](/en/perceptual-image-similarity-with-dct-and-simd).

Repository: [GitHub](https://github.com/alikoker/dct-perceptual-hash-csharp)  
Zenodo snapshot: [Zenodo](https://zenodo.org/records/22117445)  
DOI: [DOI](https://doi.org/10.5281/zenodo.22117445)

## Cite This Work

Köker, M. A. (2022). DCT Perceptual Hash. alikoker.com.tr. https://alikoker.com.tr/en/dct-perceptual-hash-csharp

- BibTeX: https://alikoker.com.tr/en/dct-perceptual-hash-csharp.bib
- RIS: https://alikoker.com.tr/en/dct-perceptual-hash-csharp.ris
- CSL-JSON: https://alikoker.com.tr/en/dct-perceptual-hash-csharp.csl.json
