Ejemplo n.º 1
0
        public static Utils.RectData[] GetRectsFromLabeledImage(Bitmap labels, Bitmap src, int numelements,
                                                                int top, int left, int bottom, int right, int background)
        {
            Utils.RectData[] occurrences = new Utils.RectData[numelements];

            for (int row = top; row < bottom; row++)
            {
                for (int col = left; col < right; col++)
                {
                    Utils.RectData rect;
                    int            label = labels[row, col];
                    if (label != background)
                    {
                        rect = occurrences[label - 1];
                        if (rect != null)
                        {
                            rect.Right  = Math.Max(col, rect.Right);
                            rect.Left   = Math.Min(col, rect.Left);
                            rect.Bottom = row;
                        }
                        else
                        {
                            rect                   = new Utils.RectData();
                            rect.Left              = col;
                            rect.Right             = col;
                            rect.Bottom            = row;
                            rect.Top               = row;
                            occurrences[label - 1] = rect;
                        }
                    }
                }
            }

            return(occurrences);
        }
Ejemplo n.º 2
0
        private bool ContentRightAligned(object v1, object v2)
        {
            Tuple <Utils.RectData, Size> pair = GetFomValuesContentEdge(v1, v2);

            Utils.RectData contentParam = pair.Item1;
            Size           featureParam = pair.Item2;

            return(featureParam.Width == contentParam.Right);
        }
Ejemplo n.º 3
0
        private static Tuple <Utils.RectData, Size> GetFomValuesContentEdge(object v1, object v2)
        {
            Utils.RectData content = v1 as Utils.RectData;
            Size           feature = v2 as Size;

            if (content == null)
            {
                content = v2 as Utils.RectData;
                feature = v1 as Size;
            }


            return(new Tuple <Utils.RectData, Size>(content, feature));
        }
Ejemplo n.º 4
0
		public static Utils.RectData[] GetRectsFromLabeledImage(Bitmap labels, Bitmap src, int numelements,
			int top, int left, int bottom, int right, int background)
		{
			Utils.RectData[] occurrences = new Utils.RectData[numelements];

			for (int row = top; row < bottom; row++)
			{
				for (int col = left; col < right; col++)
				{
					Utils.RectData rect;
					int label = labels[row, col];
					if (label != background)
					{
						rect = occurrences[label-1];
						if (rect != null)
						{
							rect.Right = Math.Max(col, rect.Right);
							rect.Left = Math.Min(col, rect.Left);
							rect.Bottom = row;
						}
						else
						{
							rect = new Utils.RectData();
							rect.Left = col;
							rect.Right = col;
							rect.Bottom = row;
							rect.Top = row;
							occurrences[label-1] = rect;
						}
					}
				}
			}

			return occurrences;
		}