Accord.Tests.Imaging.CorrelationMatchingTest.MatchTest2 C# (CSharp) Method

MatchTest2() private method

private MatchTest2 ( ) : void
return void
        public void MatchTest2()
        {
            for (int windowSize = 1; windowSize <= 15; windowSize += 2)
            {
#pragma warning disable 0618
                CorrelationMatching target = new CorrelationMatching(windowSize);
#pragma warning restore 0618

                Bitmap image1 = Accord.Imaging.Image.Clone(Properties.Resources.image1);
                Bitmap image2 = Accord.Imaging.Image.Clone(Properties.Resources.image1);

                Assert.AreEqual(16, image1.Height);
                Assert.AreEqual(16, image2.Height);

                Assert.AreEqual(16, image1.Width);
                Assert.AreEqual(16, image2.Width);

                // will test every possible point in the image
                // (and also some points outside just to make sure)
                List<IntPoint> points = new List<IntPoint>();
                for (int i = -5; i < 20; i++)
                    for (int j = -5; j < 20; j++)
                        points.Add(new IntPoint(i, j));


                // Assert that no exception if thrown
#pragma warning disable 0618
                IntPoint[][] actual = target.Match(image1, image2, points.ToArray(), points.ToArray());
#pragma warning restore 0618

                Assert.IsNotNull(actual);
                Assert.AreEqual(2, actual.Length);

                var p1 = actual[0]; var p2 = actual[1];
                Assert.AreEqual(p1.Length, p2.Length);

                
                for (int i = 0; i < p1.Length; i++)
                {
                    // As the images are the same, assert that
                    // each point correlates with itself.
                    Assert.AreEqual(p1[i], p2[i]);

                    // Also assert we have no bogus values
                    Assert.IsTrue(p1[i].X >= 0 && p1[i].X < 16);
                    Assert.IsTrue(p1[i].Y >= 0 && p1[i].Y < 16);
                }

            }
        }
    }
CorrelationMatchingTest