Ejemplo n.º 1
0
        public void Test_ToString()
        {
            using (var image = new MagickImage(Files.ImageMagickJPG))
            {
                var    phash = image.PerceptualHash();
                string hash  = phash.ToString();
                Assert.Equal(210, hash.Length);
#if Q8
                OpenCLValue.Assert("81b4488655898d38a7aa6223562032620f8a2614819b78241685c4b8c1a786f0689c9881b1f884ca8a0d38af2f622728fd3d623fedeacea78bcaedaa81d8884349824c583ad981c37895998c8658c42a628ed61b216279b81b49887348a1608af44622a3619d362371", "81b4488656898d38a7a96223562017620f7a26cd81a1e823ec85b3b8cc3186ec889ad481b1f884cb8a0d58af30622728fd41623fedea8aa78d4aeda481d8f84355824cd83ae281c378959a8c8668c42a628ec61b216279c81b49887348a1608af44622a3619d362370", hash);
#elif Q16
                OpenCLValue.Assert("81b4488652898d48a7a9622346206e620f8a649d8297d835bd86eb58c7be887e78c5f881b1e884c58a0d18af2d622718fd35623ffdeac9a78cbaedaa81d888434e824c683ad781c37895978c8688c426628ed61b216279b81b48887318a1628af43622a2619d162372", "81b4488652898d48a7a9622346206e620f8a646682939835e986ec98c78f887ae8c67f81b1e884c58a0d18af2d622718fd35623ffdeac9a78cbaedaa81d888434e824c683ad781c37895978c8688c426628ed61b216279b81b48887318a1628af43622a2619d162372", hash);
#else
                OpenCLValue.Assert("81b4488652898d48a7a9622346206e620f8a730882e4a83a9e877108d25488fc58dbb781b1e884c58a0d18af2d622718fd35623ffdeac9a78cbaedaa81d888434e824c683ad781c37895978c8688c426628ed61b216279b81b48887318a1628af43622a2619d162372", "81b4488652898d48a7a9622346206e620f8a731182e3a83aa2876d48d19488f438dcb581b1e884c58a0d18af2d622718fd35623ffdeac9a78cbaedaa81d888434e824c683ad781c37895978c8688c426628ed61b216279b81b48887318a1628af43622a2619d162372", hash);
#endif
                PerceptualHash clone = new PerceptualHash(hash);
                Assert.InRange(phash.SumSquaredDistance(clone), 0.0, 0.001);
            }
        }
Ejemplo n.º 2
0
        public void Test_SumSquaredDistance()
        {
            using (var image = new MagickImage(Files.ImageMagickJPG))
            {
                var phash = image.PerceptualHash();

                using (var other = new MagickImage(Files.MagickNETIconPNG))
                {
                    other.HasAlpha = false;
                    Assert.Equal(3, other.ChannelCount);

                    var otherPhash = other.PerceptualHash();
#if Q8
                    OpenCLValue.Assert(394.74, 394.90, phash.SumSquaredDistance(otherPhash), 0.01);
#elif Q16
                    OpenCLValue.Assert(395.35, 395.39, phash.SumSquaredDistance(otherPhash), 0.02);
#else
                    OpenCLValue.Assert(395.60, 395.68, phash.SumSquaredDistance(otherPhash), 0.02);
#endif
                }
            }
        }
Ejemplo n.º 3
0
        public void Test_ToString()
        {
            using (MagickImage image = new MagickImage(Files.ImageMagickJPG))
            {
                PerceptualHash phash = image.PerceptualHash();
                string         hash  = phash.ToString();
                Assert.AreEqual(210, hash.Length);
#if Q8
                OpenCLValue.Assert("81b4488655898d38a7a9622356203b620f8a257faffcd823c685c228bed086e9c89c3b81b1f884c98a0d38af2f622728fd3d623fedeb01a78a7aed9381d8684342824c283ad681c378959a8c86b8c429628ee61b216279b81b49887338a1608af44622a3619d362371",
                                   "81b4488656898d38a7a96223562017620f7a26cf81a12823dd85b948bf8d86e5d89b6b81b1f884cb8a0d38af2f622728fd3f623fedeac7a78beaed8d81d8984349824c783ada81c378959b8c86a8c42b628ed61b216279c81b49887348a15f8af43622a3619d362370", hash);
#elif Q16
                OpenCLValue.Assert("81b4488651898d38a7a8622346206c620f8a64ba8293d835f086f338cb378897b8c52581b1e884c58a0d18af2d622718fd35623ffdeaeda78b3aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372",
                                   "81b4488651898d38a7a8622346206c620f8a648f8290a8361086f778ca5d889098c65381b1e884c58a0d18af2d622718fd35623ffdeaeda78b3aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372", hash);
#elif Q16HDRI
                OpenCLValue.Assert("81b4488651898d48a7a8622346206c620f8a725f82deb83a96878108d4c2891118dad981b1e884c58a0d18af2d622718fd35623ffdeaeda78b4aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372",
                                   "81b4488651898d38a7a8622346206b620f8a728e82dde83ac4878188d4b2890f58db6b81b1e884c58a0d18af2d622718fd35623ffdeaeda78b4aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372", hash);
#else
#error Not implemented!
#endif
                PerceptualHash clone = new PerceptualHash(hash);
                Assert.AreEqual(0.0, phash.SumSquaredDistance(clone), 0.001);
            }
        }
Ejemplo n.º 4
0
            public void ShouldModulateImage()
            {
                using (var image = new MagickImage(Files.TestPNG))
                {
                    image.Modulate(new Percentage(70), new Percentage(30));

#if Q8
                    ColorAssert.Equal(new MagickColor("#743e3e"), image, 25, 70);
                    ColorAssert.Equal(new MagickColor("#0b0b0b"), image, 25, 40);
                    ColorAssert.Equal(new MagickColor("#1f3a1f"), image, 75, 70);
                    ColorAssert.Equal(new MagickColor("#5a5a5a"), image, 75, 40);
                    ColorAssert.Equal(new MagickColor("#3e3e74"), image, 125, 70);
                    ColorAssert.Equal(new MagickColor("#a8a8a8"), image, 125, 40);
#else
                    ColorAssert.Equal(new MagickColor(OpenCLValue.Get("#72803da83da8", "#747a3eb83eb8")), image, 25, 70);
                    ColorAssert.Equal(new MagickColor(OpenCLValue.Get("#0b2d0b2d0b2d", "#0b5f0b5f0b5f")), image, 25, 40);
                    ColorAssert.Equal(new MagickColor(OpenCLValue.Get("#1ef3397a1ef3", "#1f7c3a781f7c")), image, 75, 70);
                    ColorAssert.Equal(new MagickColor(OpenCLValue.Get("#592d592d592d", "#5ab75ab75ab7")), image, 75, 40);
                    ColorAssert.Equal(new MagickColor(OpenCLValue.Get("#3da83da87280", "#3eb83eb8747a")), image, 125, 70);
                    ColorAssert.Equal(new MagickColor(OpenCLValue.Get("#a5aea5aea5ae", "#a88ba88ba88b")), image, 125, 40);
#endif
                }
            }
Ejemplo n.º 5
0
        public void Test_SumSquaredDistance()
        {
            using (MagickImage image = new MagickImage(Files.ImageMagickJPG))
            {
                PerceptualHash phash = image.PerceptualHash();

                using (MagickImage 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.27, 311.27, phash.SumSquaredDistance(otherPhash), 0.02);
#else
#error Not implemented!
#endif
                }
            }
        }
Ejemplo n.º 6
0
 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);
 }