Ejemplo n.º 1
0
        public void WeightingTest()
        {
            Console.WriteLine("Weighting Testing Begin...");
            var expected = new[] { 0.4, 0.3, 0.2, 0.1 };
            var actual   = Luminousity.LinearWeighting(4);

            Assert.IsTrue(expected.Length == actual.Length);
            for (int ii = 0; ii < expected.Length; ii++)
            {
                Assert.IsTrue(Math.Abs(Math.Round(10 * expected[ii]) - Math.Round(10 * actual[ii])) < 0.001);
            }
            Console.WriteLine("Weighting Successful");
        }
Ejemplo n.º 2
0
        public void ArrayRepresentativeTest()
        {
            Console.WriteLine("Starting Luma( Color Array) Test");

            var colors = new Bgra[4];

            colors[0] = new Bgra(0, 0, 100, 0);
            colors[1] = new Bgra(0, 0, 90, 0);
            colors[2] = new Bgra(0, 0, 100, 0);
            colors[3] = new Bgra(0, 0, 100, 0);
            var expected = Luminousity.Luma(new Bgra(0, 0, (40 + 27 + 20 + 10), 0));
            var actual   = Luminousity.RepresentativeLuma(colors, Luminousity.LinearWeighting(colors.Length));

            Assert.IsTrue(Math.Abs(actual - expected) < 0.01);
            Console.WriteLine("Representative of Array Luma Test Successful");
        }