3DRadSpace 0.1.0Alpha
3DRadSpace is a free, simple to use, rapid application development game engine.
Loading...
Searching...
No Matches
Engine3DRadSpace::Testing::PerceptualHash Class Reference

Perceptual hash using dHash (difference hash) algorithm. Compares structural similarity between images regardless of minor pixel differences. More...

#include <PerceptualHash.hpp>

Public Types

using Hash = uint64_t

Static Public Member Functions

static Hash ComputeHash (const std::filesystem::path &imagePath)
 Computes perceptual hash for an image file.
static unsigned HammingDistance (Hash hash1, Hash hash2)
 Calculates Hamming distance between two hashes (number of differing bits). Lower distance = more similar images.
static bool AreImagesSimilar (const std::filesystem::path &imagePath1, const std::filesystem::path &imagePath2, unsigned threshold=5)
 Checks if two images are perceptually similar.

Detailed Description

Perceptual hash using dHash (difference hash) algorithm. Compares structural similarity between images regardless of minor pixel differences.

Member Typedef Documentation

◆ Hash

Member Function Documentation

◆ AreImagesSimilar()

bool Engine3DRadSpace::Testing::PerceptualHash::AreImagesSimilar ( const std::filesystem::path & imagePath1,
const std::filesystem::path & imagePath2,
unsigned threshold = 5 )
static

Checks if two images are perceptually similar.

Parameters
imagePath1Path to first image
imagePath2Path to second image
thresholdMaximum allowed Hamming distance (default: 5, typically 0-10 for similar images)
Returns
True if images are similar within threshold

◆ ComputeHash()

PerceptualHash::Hash Engine3DRadSpace::Testing::PerceptualHash::ComputeHash ( const std::filesystem::path & imagePath)
static

Computes perceptual hash for an image file.

Parameters
imagePathPath to the image file
Returns
64-bit perceptual hash

◆ HammingDistance()

unsigned Engine3DRadSpace::Testing::PerceptualHash::HammingDistance ( Hash hash1,
Hash hash2 )
static

Calculates Hamming distance between two hashes (number of differing bits). Lower distance = more similar images.

Parameters
hash1First hash
hash2Second hash
Returns
Hamming distance (0-64)

The documentation for this class was generated from the following files: