pHash cross correlation of two white images is 0

205 Views Asked by At

I'm using Shipwreck.Phash for image comparison. I just recognized that two identical white images return a cross correlation of 0, although it should return 1.

hash1: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000

hash2: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000

CrossCorrelation: 0

My code:

static void Main(string[] args)
    {


        var firstImage = new Bitmap(@"Bilder\\hash1.JPG");
        var secondImage = new Bitmap(@"Bilder\\hash1.JPG");


        var hash = ImagePhash.ComputeDigest(firstImage.ToLuminanceImage());
        var hash2 = ImagePhash.ComputeDigest(secondImage.ToLuminanceImage());

        var score = ImagePhash.GetCrossCorrelation(hash, hash2);

        Console.WriteLine(hash);
        Console.WriteLine(hash2);

        Console.WriteLine(score);


    }

Can someone please explain me my result? Thanks in advance.

Given image: whiteImage

1

There are 1 best solutions below

0
On BEST ANSWER

I asked the Shipwreck Developers directly and that is their answer:

As the cross-correlation calculation is based on a kind of division, it doesn't support zero vectors. So the pHash doesn't support single-color-image.

Implementing the fiddle from @Bagus Tesa it is working, although it's a copy from Shipwreck.Phash. Therefore I changed the CrossCorrelation method from the NuGet to his.