/// <summary> /// Returns pixels for each region /// </summary> /// <param name="msResult"></param> public static Dictionary <int, Bgr[]> GetRegionsPixels(MeanShiftClusteringResult msResult) { //key - region nuber //value - region pixels coordinates Dictionary <int, Bgr[]> result = new Dictionary <int, Bgr[]>(); throw new NotImplementedException(); return(result); }
/// <summary> /// Returns pixels coordinates for each region /// </summary> /// <param name="msResult"></param> public static Dictionary <int, List <PixelCoordinates> > GetRegionsPixelsCoordinates(MeanShiftClusteringResult msResult) { //key - region number //value - region pixels coordinates Dictionary <int, List <PixelCoordinates> > result = new Dictionary <int, List <PixelCoordinates> >(); for (int m = 0; m < msResult.Image.Rows; m++) { for (int n = 0; n < msResult.Image.Cols; n++) { Bgr pixel = msResult.Image[m, n]; //int index = msResult.Image.Width * m + n; int index = msResult.Image.Rows * m + n; int label = msResult.Labels[index]; int regionNumber = label; //Init key in dictionary if (result.ContainsKey(regionNumber) == false) { result.Add(regionNumber, new List <PixelCoordinates>()); } //Add pixel result[regionNumber].Add(new PixelCoordinates() { X = m, Y = n }); } } //throw new NotImplementedException(); return(result); }