コード例 #1
0
        //The size of a shape is the number of pixels in a shape
        //To find out the maximum size of shape in a bitmap - Shape0.bmp
        public int GetMaxSizeOfShape()
        {
            LoadImage();
            var sizeList = new MicrosoftResearch.Infer.Collections.SortedSet <int>();
            int size     = 0;

            var pict        = image.Size;
            int shapeNumber = 1;

            for (int j = 0; j < pict.Height; j++)
            {
                for (int i = 0; i < pict.Width; i++)
                {
                    int currShapeSize = FindShapeSize(i, j);

                    if (currShapeSize > 0 && !sizeList.Contains(currShapeSize))
                    {
                        sizeList.Add(currShapeSize);
                        string filename = String.Format("{0}_{1}_{2}.{3}", FileName, shapeNumber, currShapeSize, FileExt);
                        shapeNumber++;
                        Save(filename);
                    }
                }
            }

            if (sizeList.Count > 0)
            {
                size = sizeList[sizeList.Count - 1];
            }
            return(size);
        }
コード例 #2
0
        //The size of a shape is the number of pixels in a shape
        //To find out the maximum size of shape in a bitmap - Shape0.bmp
        public int GetMaxSizeOfShape()
        {
            LoadImage();
            //To store size of shapes
            var sizeList = new MicrosoftResearch.Infer.Collections.SortedSet <int>();

            //To store black pixels on top of red lines
            BlackPixelList = new MicrosoftResearch.Infer.Collections.SortedSet <BlackPixel>(new SortedByBlackPixel());

            int  size        = 0;
            var  pict        = image.Size;
            int  shapeNumber = 1;
            int  i           = 0;
            int  j           = 0;
            bool bFound      = false;

            do
            {
                bFound = Fine_A_Black_Pixel(ref i, ref j);

                if (bFound)
                {
                    int currShapeSize = FindShapeSize(i, j);
                    if (currShapeSize > 0 && !sizeList.Contains(currShapeSize))
                    {
                        sizeList.Add(currShapeSize);
                        string filename = String.Format("{0}_{1}_{2}.{3}", FileName, shapeNumber, currShapeSize, FileExt);
                        shapeNumber++;
                        Save(filename);
                    }
                }
            } while (bFound);

            if (sizeList.Count > 0)
            {
                size = sizeList[sizeList.Count - 1];
            }
            return(size);
        }