Exemple #1
0
        public void GetDerivativeTest()
        {
            var flatImage    = LoadFlatImageFromResource("ScreenGrid.Tests.Resources.ImageSimple.png");
            var stripeMiddle = flatImage.GetHorizontalStripe(flatImage.Height / 2);

            var dMiddle = FlatImage.GetDerivative(stripeMiddle);

            Assert.AreEqual(stripeMiddle.Length, dMiddle.Length);

            // Border detection
            Assert.AreEqual(0, dMiddle[11]);
            Assert.Greater(dMiddle[12], 0);
        }
Exemple #2
0
        public void FindBordersTest()
        {
            var flatImage = LoadFlatImageFromResource("ScreenGrid.Tests.Resources.ImageSimple.png");

            const int minimalSegmentLength = 8;
            var       step = flatImage.Height / 8;

            var list = new List <Tuple <int, int> >();

            for (var iy = minimalSegmentLength + step; iy < flatImage.Height - (minimalSegmentLength + step); iy += step)
            {
                var stripe     = flatImage.GetHorizontalStripe(iy);
                var derivative = FlatImage.GetDerivative(stripe);
                var segments   = IntegerSegmentUtils.FindZeroSegments(derivative, minimalSegmentLength);

                Assert.AreEqual(2, segments.Count, String.Format("iy={0}", iy));
            }
        }