コード例 #1
0
        public void MedianOneXTwo() // 1x2
        {
            var original = new double[, ] {
                { 0.1, 0.3 }
            };
            var actual = MedianFiltere.GetMedian(original, 0, 0);

            Assert.AreEqual(0.2, actual);
        }
コード例 #2
0
        public void MedianOneXOne() //1x1
        {
            var original = new double[, ] {
                { 3 }
            };
            var actual = MedianFiltere.GetMedian(original, 0, 0);

            Assert.AreEqual(3, actual);
        }
コード例 #3
0
        public void MedianFilterTreeXTwo() // 3x2
        {
            var original = new double[, ] {
                { 1, 0 }, { 1, 1 }, { 1, 1 }
            };
            var actual  = MedianFiltere.MedianFilter(original);
            var exepted = new double[, ] {
                { 1, 1 }, { 1, 1 }, { 1, 1 }
            };

            Assert.AreEqual(exepted, actual);
        }
コード例 #4
0
        public void MedianFilterOneXTwo() // 1x2
        {
            var original = new double[, ] {
                { 0.1, 0.3 }
            };
            var actual  = MedianFiltere.MedianFilter(original);
            var exepted = new double[, ] {
                { 0.2, 0.2 }
            };

            Assert.AreEqual(exepted, actual);
        }
コード例 #5
0
        private static void Main()
        {
            var bmp    = (Bitmap)Image.FromFile("eurobot.bmp");
            var pixels = LoadPixels(bmp);

            var form = new Form
            {
                ClientSize = new Size(3 * ResizeRate * bmp.Width, 2 * ResizeRate * bmp.Height)
            };

            var panel = new TableLayoutPanel
            {
                RowCount    = 2,
                ColumnCount = 3,
                Dock        = DockStyle.Fill
            };

            form.Controls.Add(panel);

            panel.Controls.Add(CreateBox(ConvertToBitmap(pixels)), 0, 0);
            var grayscale = Grayscale.ToGrayscale(pixels);

            panel.Controls.Add(CreateBox(ConvertToBitmap(grayscale)), 1, 0);
            var clear = MedianFiltere.MedianFilter(grayscale);

            panel.Controls.Add(CreateBox(ConvertToBitmap(clear)), 2, 0);
            var sobell = SobelFilterClass.SobelFilter(clear, new double[, ] {
                { -1, -2, -1 }, { 0, 0, 0 }, { 1, 2, 1 }
            });

            panel.Controls.Add(CreateBox(ConvertToBitmap(sobell)), 0, 1);
            var trashhold = ThresholdFilterClass.ThresholdFilter(sobell, 0.1);

            panel.Controls.Add(CreateBox(ConvertToBitmap(trashhold)), 1, 1);

            var bitmap = ConvertToBitmap(sobell);

            using (var g = Graphics.FromImage(bitmap))
            {
                var lines = HoughTransform.HoughAlgorithm(sobell);
                var pen   = new Pen(Color.Red, 2);
                foreach (var e in lines)
                {
                    g.DrawLine(pen, e.X0 * ResizeRate, e.Y0 * ResizeRate, e.X1 * ResizeRate, e.Y1 * ResizeRate);
                }
            }

            panel.Controls.Add(CreateBox(bitmap), 2, 1);
            Application.Run(form);
        }