コード例 #1
0
        public void ShouldAdd14ValuesAndNotBlowUpInt()
        {
            var imf = new IntMedianFilter(12);

            /* Add twelve of same items, should return same value back as average */
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));


            Assert.AreEqual(8, imf.Filtered.X);
            Assert.AreEqual(12, imf.Filtered.Y);
        }
コード例 #2
0
        public void OneValueShouldReturnThatAsAverage()
        {
            var imf = new IntMedianFilter();

            imf.Add(new Core.Models.Drawing.Point2D <int>(5, 8));
            Assert.AreEqual(5, imf.Filtered.X);
            Assert.AreEqual(8, imf.Filtered.Y);
        }
コード例 #3
0
        public void TwoValueShouldReturnAverageOfTwoValues()
        {
            var imf = new IntMedianFilter();

            imf.Add(new Core.Models.Drawing.Point2D <int>(4, 8));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            Assert.AreEqual(6, imf.Filtered.X);
            Assert.AreEqual(10, imf.Filtered.Y);
        }
コード例 #4
0
        public void ShouldThrowOutThreeHightestValues()
        {
            var imf = new IntMedianFilter(12, 3);

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 99));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(32, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 16));
            imf.Add(new Core.Models.Drawing.Point2D <int>(34, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(89, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 42));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            Assert.AreEqual(8, imf.Filtered.X);
            Assert.AreEqual(12, imf.Filtered.Y);
        }
コード例 #5
0
        public void ShouldThrowOutThreeLowstValues()
        {
            var imf = new IntMedianFilter(12, 3);

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(3, 7));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(2, 9));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 6));
            imf.Add(new Core.Models.Drawing.Point2D <int>(5, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            Assert.AreEqual(8, imf.Filtered.X);
            Assert.AreEqual(12, imf.Filtered.Y);
        }
コード例 #6
0
        public void FitlerSizeValueShouldReturnAverageOfNMedianValues()
        {
            var imf = new IntMedianFilter(12);

            /* Add twelve of same items, should return same value back as average */
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));
            imf.Add(new Core.Models.Drawing.Point2D <int>(8, 12));

            Assert.AreEqual(8, imf.Filtered.X);
            Assert.AreEqual(12, imf.Filtered.Y);
        }
コード例 #7
0
        public void ShouldAverageMiddle6Values()
        {
            var imf = new IntMedianFilter(12);

            /* Add twelve of same items, should return same value back as average */
            imf.Add(new Core.Models.Drawing.Point2D <int>(6, 10));
            imf.Add(new Core.Models.Drawing.Point2D <int>(3, 8));
            imf.Add(new Core.Models.Drawing.Point2D <int>(10, 14));
            imf.Add(new Core.Models.Drawing.Point2D <int>(14, 21));

            imf.Add(new Core.Models.Drawing.Point2D <int>(10, 14));
            imf.Add(new Core.Models.Drawing.Point2D <int>(5, 44));
            imf.Add(new Core.Models.Drawing.Point2D <int>(44, 9));
            imf.Add(new Core.Models.Drawing.Point2D <int>(10, 10));

            imf.Add(new Core.Models.Drawing.Point2D <int>(6, 32));
            imf.Add(new Core.Models.Drawing.Point2D <int>(32, 14));
            imf.Add(new Core.Models.Drawing.Point2D <int>(2, 10));
            imf.Add(new Core.Models.Drawing.Point2D <int>(6, 10));

            Assert.AreEqual(8, imf.Filtered.X);
            Assert.AreEqual(12, imf.Filtered.Y);
        }
コード例 #8
0
        public void NullValueTest()
        {
            var imf = new IntMedianFilter();

            Assert.IsNull(imf.Filtered);
        }