Esempio n. 1
0
        private void fitCircleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Vector2> gaussian_i_pts = new List <Vector2>();

            foreach (Vector2 pt in gmm.pts)
            {
                if (pt.gaussian_idx[manual_level - 1] == selected_gaussian_idx)
                {
                    gaussian_i_pts.Add(pt);
                }
            }

            if (gaussian_i_pts.Count < 3)
            {
                return;
            }

            BaseModel circleModel = new CircleModel();

            circleModel = RANSAC.Fit(gaussian_i_pts, circleModel, 3, circle_res);
            gmm.baseModels.Add(circleModel);

            drawingGaussians[selected_gaussian_idx].dropped   = true;
            drawingGaussians[selected_gaussian_idx].selected  = false;
            gmm.gaussian_list[selected_gaussian_idx].dropped  = true;
            gmm.gaussian_list[selected_gaussian_idx].selected = false;

            this.Refresh();
            // TODO: deep copy of gmm.gaussian_list
            //gmm.gaussian_list[selected_gaussian_idx].dropped = false;
        }
Esempio n. 2
0
        public void DetectLastLevel(int level)
        {
            IEnumerable <int> level_gaussians = GetLevel(level - 1);

            foreach (int i in level_gaussians)
            {
                List <Vector2> gaussian_i_pts = new List <Vector2>();

                foreach (Vector2 pt in pts)
                {
                    if (pt.gaussian_idx[level - 1] == i)
                    {
                        gaussian_i_pts.Add(pt);
                    }
                }

                if (gaussian_i_pts.Count < 2)
                {
                    continue;
                }

                BaseModel lineModel = new LineModel();
                lineModel = RANSAC.Fit(gaussian_i_pts, lineModel, 2, 2.00F);
                baseModels.Add(lineModel);
            }
        }
Esempio n. 3
0
        private List <Gaussian_2D> ClusteringInitGMM(int level, int init_type)
        {
            List <Gaussian_2D> cluster_list = new List <Gaussian_2D>();

            if (level != 0)
            {
                IEnumerable <int> parent_level_gaussians = GetLevel(level - 1);
                foreach (int i in parent_level_gaussians)
                {
                    List <Vector2>     parent_pts     = new List <Vector2>();
                    List <Gaussian_2D> cluster_list_i = new List <Gaussian_2D>();

                    foreach (Vector2 pt in pts)
                    {
                        if (pt.gaussian_idx[level - 1] == i)
                        {
                            parent_pts.Add(pt);
                        }
                    }

                    //if there are fewer points than num_gaussian * 2 in the parent gaussian, stop partition
                    //if (parent_pts.Count <= num_gaussian * 2 || gaussian_list[i].partition == false)
                    if (parent_pts.Count < num_gaussian || gaussian_list[i].partition == false)
                    {
                        Console.WriteLine("===========Stopping at gaussian {0}==============", i);
                        //gaussian_list[i].partition = false;
                        for (int j = 0; j < num_gaussian; j++)
                        {
                            Gaussian_2D gau = new Gaussian_2D();
                            gau.partition = false;
                            gau.dropped   = true;
                            cluster_list_i.Add(gau);
                        }
                        cluster_list = cluster_list.Concat(cluster_list_i).ToList();

                        if (parent_pts.Count > 2 && gaussian_list[i].dropped == false)
                        {
                            BaseModel lineModel = new LineModel();
                            lineModel = RANSAC.Fit(parent_pts, lineModel, 2, 2.00F);
                            baseModels.Add(lineModel);
                        }

                        continue;
                    }

                    if (init_type == 1)
                    {
                        cluster_list_i = FuzzyCMeans.fit(parent_pts, num_gaussian);
                    }
                    else if (init_type == 0)
                    {
                        cluster_list_i = KMeans.fit(parent_pts, num_gaussian);
                    }
                    cluster_list = cluster_list.Concat(cluster_list_i).ToList();
                }
            }
            else
            {
                if (init_type == 1)
                {
                    cluster_list = FuzzyCMeans.fit(pts, num_gaussian);
                }
                else if (init_type == 0)
                {
                    cluster_list = KMeans.fit(pts, num_gaussian);
                }
            }

            return(cluster_list);
        }