Contains the he perceptual hash of one or more image channels.
Пример #1
0
        ///<summary>
        /// Returns the sum squared difference between this hash and the other hash.
        ///</summary>
        ///<param name="other">The PerceptualHash to get the distance of.</param>
        public double SumSquaredDistance(PerceptualHash other)
        {
            Throw.IfNull("other", other);

            return
                (_Channels[PixelChannel.Red].SumSquaredDistance(other._Channels[PixelChannel.Red]) +
                 _Channels[PixelChannel.Green].SumSquaredDistance(other._Channels[PixelChannel.Green]) +
                 _Channels[PixelChannel.Blue].SumSquaredDistance(other._Channels[PixelChannel.Blue]));
        }
Пример #2
0
    /// <summary>
    /// Returns the sum squared difference between this hash and the other hash.
    /// </summary>
    /// <param name="other">The <see cref="PerceptualHash"/> to get the distance of.</param>
    /// <returns>The sum squared difference between this hash and the other hash.</returns>
    public double SumSquaredDistance(PerceptualHash other)
    {
      Throw.IfNull(nameof(other), other);

      return
        _Channels[PixelChannel.Red].SumSquaredDistance(other._Channels[PixelChannel.Red]) +
        _Channels[PixelChannel.Green].SumSquaredDistance(other._Channels[PixelChannel.Green]) +
        _Channels[PixelChannel.Blue].SumSquaredDistance(other._Channels[PixelChannel.Blue]);
    }
Пример #3
0
    public void Test_ToString()
    {
      /* VS2008 compiler produces different results, no clue why this is happening */
#if NET20
      return;
#endif

      using (MagickImage image = new MagickImage(Files.ImageMagickJPG))
      {
        PerceptualHash phash = image.PerceptualHash();
        string hash = phash.ToString();
        Assert.AreEqual(210, hash.Length);
#if Q8
        Assert.AreEqual("81b4488656898d38a7a96223562017620f7a26cf81a12823dd85b948bf8d86e5d89b6b81b1f884cb8a0d38af2f622728fd3f623fedeac7a78beaed8d81d8984349824c783ada81c378959b8c86a8c42b628ed61b216279c81b49887348a15f8af43622a3619d362370", hash);
#elif Q16
        Assert.AreEqual("81b4488651898d38a7a8622346206c620f8a648f8290a8361086f778ca5d889098c65381b1e884c58a0d18af2d622718fd35623ffdeaeda78b3aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372", hash);
#elif Q16HDRI
        Assert.AreEqual("81b4488651898d38a7a8622346206b620f8a728e82dde83ac4878188d4b2890f58db6b81b1e884c58a0d18af2d622718fd35623ffdeaeda78b4aeda581d8484344824c083ad281c37895978c86d8c425628ee61b216279b81b48887318a1628af42622a2619d162372", hash);
#else
#error Not implemented!
#endif
        PerceptualHash clone = new PerceptualHash(hash);
        Assert.AreEqual(0.0, phash.SumSquaredDistance(clone), 0.001);
      }
    }
Пример #4
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);
      }
    }