public void Test_ToString() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { PerceptualHash phash = image.PerceptualHash(); string hash = phash.ToString(); Assert.AreEqual(210, hash.Length); #if Q8 OpenCLValue.Assert("81b4488655898d38a7a9622356203b620f8a257faffcc823c685c228bed086e9c89c3b81b1f884c98a0d38af2f622728fd3d623fedeb01a78a7aed9381d8684342824c283ad681c378959a8c86b8c429628ee61b216279b81b49887338a1608af44622a3619d362371", "81b4488656898d38a7a96223562017620f7a26cf81a12823dd85b948bf8f86e5e89b6b81b1f884cb8a0d38af2f622728fd3f623fedeac7a78beaed8d81d8984349824c783ada81c378959b8c86a8c42b628ed61b216279c81b49887348a15f8af43622a3619d362370", hash); #elif Q16 OpenCLValue.Assert("81b4488651898d38a7a8622346206c620f8a64bb8293d835f086f348cb368897a8c52881b1e884c58a0d18af2d622718fd35623ffdeaeda78b3aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372", "81b4488651898d38a7a8622346206c620f8a64888290c8360a86f668ca7b889168c61481b1e884c58a0d18af2d622718fd35623ffdeaeda78b3aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372", hash); #elif Q16HDRI OpenCLValue.Assert("81b4488651898d38a7a8622346206b620f8a726582de983a9b878148d4d5891188daca81b1e884c58a0d18af2d622718fd35623ffdeaeda78b4aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372", "81b4488651898d38a7a8622346206b620f8a728c82ddf83aa9877da8d455890bc8dae081b1e884c58a0d18af2d622718fd35623ffdeaeda78b4aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372", hash); #else #error Not implemented! #endif PerceptualHash clone = new PerceptualHash(hash); Assert.AreEqual(0.0, phash.SumSquaredDistance(clone), 0.001); } }
public void Test_SumSquaredDistance() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { PerceptualHash phash = image.PerceptualHash(); using (IMagickImage other = new MagickImage(Files.MagickNETIconPNG)) { other.HasAlpha = false; Assert.AreEqual(3, other.ChannelCount); PerceptualHash otherPhash = other.PerceptualHash(); #if Q8 OpenCLValue.Assert(312.06, 311.71, phash.SumSquaredDistance(otherPhash), 0.01); #elif Q16 OpenCLValue.Assert(311.40, 311.45, phash.SumSquaredDistance(otherPhash), 0.02); #elif Q16HDRI OpenCLValue.Assert(311.24, 311.27, phash.SumSquaredDistance(otherPhash), 0.02); #else #error Not implemented! #endif } } }
private void TestChannel(ChannelPerceptualHash channel, int index, double srgbHuPhashWithOpenCL, double srgbHuPhashWithoutOpenCL, double hclpHuPhashWithOpenCL, double hclpHuPhashWithoutOpenCL) { OpenCLValue.Assert(srgbHuPhashWithOpenCL, srgbHuPhashWithoutOpenCL, channel.SrgbHuPhash(index), 0.0001); OpenCLValue.Assert(hclpHuPhashWithOpenCL, hclpHuPhashWithoutOpenCL, channel.HclpHuPhash(index), 0.0001); }