Exemplo n.º 1
0
        public void RansacLineConstructorTest2()
        {
            Accord.Math.Tools.SetupGenerator(0);

            Bitmap image = Resources.noise_line;

            //Accord.Controls.ImageBox.Show(image); 

            var detector = new SusanCornersDetector();

            List<IntPoint> cloud = detector.ProcessImage(image);
            Assert.AreEqual(211, cloud.Count);

            Bitmap marks = new PointsMarker(cloud, Color.Pink).Apply(image);
            //Accord.Controls.ImageBox.Show(marks);

            RansacLine ransac = new RansacLine(5, 1e-10);
            Line line = ransac.Estimate(cloud);

            Assert.AreEqual(0.501134932f, line.Intercept);
            Assert.AreEqual(-0.865369201f, line.Slope);

            //var result = new LineMarker(line).Apply(image);
            //Accord.Controls.ImageBox.Show(result);
        }
Exemplo n.º 2
0
        public void RansacLineConstructorTest()
        {
            Point[] points = new Point[500];

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i;
                    double y = i; //+ 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual = target.Estimate(points);
                Line expected = Line.FromPoints(points[0], points[499]);

                Assert.AreEqual(expected.Slope, actual.Slope, 1e-3);
                Assert.AreEqual(expected.Intercept, actual.Intercept, 1e-2);
            }

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i;
                    double y = i + 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual = target.Estimate(points);

                Assert.AreEqual(1.0, actual.Slope, 1e-3);
                Assert.AreEqual(0.0, actual.Intercept, 1e-2);
            }

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i + 50;
                    double y = i + 50 + 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual = target.Estimate(points);

                Assert.AreEqual(1.0, actual.Slope, 1e-3);
                Assert.AreEqual(0.0, actual.Intercept, 1e-2);
            }
        }
Exemplo n.º 3
0
        public void RansacLineConstructorTest2()
        {
            Bitmap image = Properties.Resources.noise_line;

            ImageBox.Show(image); 

            var detector = new SusanCornersDetector();

            List<IntPoint> cloud = detector.ProcessImage(image);

            Bitmap marks = new PointsMarker(cloud, Color.Pink).Apply(image);
            ImageBox.Show(marks);

            RansacLine ransac = new RansacLine(5, 1e-10);
            Line line = ransac.Estimate(cloud);

            Bitmap result = new LineMarker(line).Apply(image);
            ImageBox.Show(result);

            Assert.Fail();
        }