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); }