Exemple #1
0
        public void ComputeDigest(int seed)
        {
            const int W = 128;
            const int H = 128;

            var d = new byte[W * H];
            var r = new Random(seed);

            r.NextBytes(d);

            var head   = ImagePhash.ComputeDigest(new ByteImage(W, H, d));
            var v0_3_6 = V0_3_6.ImagePhash.ComputeDigest(new V0_3_6.Imaging.ByteImage(W, H, d));

            var cc = ImagePhash.GetCrossCorrelation(head.Coefficients, v0_3_6.Coefficients);

            _Output.WriteLine($"ImagePhash.GetCrossCorrelation: {cc}");
            Assert.Equal(1, cc, 3);
        }
Exemple #2
0
        public void GetCrossCorrelationTest(int seed)
        {
            _Output.WriteLine("Vector<float>.Count: {0}", Vector <float> .Count);
            _Output.WriteLine("Vector.IsHardwareAccelerated: {0}", Vector.IsHardwareAccelerated);

            var a = new byte[40];
            var b = new byte[40];

            for (var i = 0; i < 100; i++)
            {
                var r = new Random(seed);

                r.NextBytes(a);
                r.NextBytes(b);

                var expected = GetCrossCorrelationSimple(a, b, 40);
                var actual   = ImagePhash.GetCrossCorrelation(a, b);

                Assert.Equal(expected, actual, 5);
            }
        }