コード例 #1
0
        private void btnOutlierRem_Click(object sender, EventArgs e)
        {
            panRemoval.Controls.Clear();
            List <Point> cleanedShape1 = new List <Point>();
            List <Point> cleanedShape2 = new List <Point>();
            Ransac       RansacForm    = new Ransac();

            if (DialogResult.OK == RansacForm.ShowDialog())
            {
                double         bestCost   = 0;
                Transformation bestT      = null;
                int            n          = (int)(RansacForm.InitPercent * Shape1.Count);
                int            d          = (int)(RansacForm.TotalPercent * Shape1.Count);
                double         tresh      = RansacForm.Treshold;
                int            iterations = RansacForm.Iterations;
                utils.Ransac(Shape1, Shape2, n, tresh, d, iterations, ref cleanedShape1, ref cleanedShape2, ref bestCost, ref bestT);
                if (bestT != null)
                {
                    //We found a transformation though ransac
                    cleanedShape2 = utils.ApplyTransformation(bestT, cleanedShape2);
                    DrawOnPanel(panRemoval, cleanedShape1, cleanedShape2);
                    String s = "Iter: {0}, N: {1}, D: {2}, Tresh:{3}";
                    MessageBox.Show(String.Format(s, iterations, n, d, tresh));
                }
                else
                {
                    MessageBox.Show("No good transformation found!");
                }
            }
        }
コード例 #2
0
        private void OutlierRemove_OnClick_Click(object sender, RoutedEventArgs e)
        {
            if (isRansac.IsChecked == true)
            {
                if (Ransac.GetRansac(shape1, shape2, 3, 10, 500, 6) == false)
                {
                    MessageBox.Show("Could not remove outliers with Ransac");
                }
            }
            else
            {
                BruteForce.RemoveOutliers(shape1, shape2);
            }

            T       = new Transformation(shape1, shape2);
            shape2T = T.Apply(shape2);
            Images3.Children.Add(DrawImage(shape1, Brushes.Blue));
            Images3.Children.Add(DrawImage(shape2T, Brushes.Red));
        }