public void RansacLineConstructorTest2() { Accord.Math.Random.Generator.Seed = 0; Bitmap image = Accord.Imaging.Image.Clone(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, 1e-5); Assert.AreEqual(-0.865369201f, line.Slope, 1e-5); //var result = new LineMarker(line).Apply(image); //Accord.Controls.ImageBox.Show(result); }
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); } }
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(); }