简体   繁体   中英

pHash cross correlation of two white images is 0

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM