示例#1
0
        /// <summary>
        /// This method returns coverage with blacke points on one squre defined by points
        /// </summary>
        /// <param name="pointSet"></param>
        /// <param name="bitMap"></param>
        /// <returns></returns>
        private double CountBlackWhite(PointsStartEnd pointSet, Bitmap bitMap)
        {
            double result     = 0;
            int    whiteCount = 0;
            int    blackCount = 0;

            for (int x = pointSet.strat.X; x < pointSet.end.X; x++)
            {
                for (int y = pointSet.strat.Y; y < pointSet.end.Y; y++)
                {
                    Color pixelColor = bitMap.GetPixel(x, y);
                    //zlicznaie baiłych pikseli
                    if (pixelColor.R + pixelColor.G + pixelColor.B >= 250)
                    {
                        whiteCount++;
                    }
                    //zliczanie czarnych pikseli
                    if (pixelColor.R + pixelColor.G + pixelColor.B == 0)
                    {
                        blackCount++;
                    }
                }
            }
            int height  = pointSet.end.Y - pointSet.strat.Y;
            int width   = pointSet.end.X - pointSet.strat.X;
            int content = height * width;

            result = (double)blackCount / (double)content;
            return(result);
        }
示例#2
0
        /// <summary>
        /// This method determine latice (siatke) on character image
        /// </summary>
        /// <param name="img"></param>
        /// <returns>list of points with first and last Point from space</returns>
        private List <PointsStartEnd> CreatePointsTable(Bitmap img)
        {
            List <PointsStartEnd> list = new List <PointsStartEnd>();
            int imgHeight        = img.Height;
            int imgWidth         = img.Width;
            int imgWidthDivided  = imgWidth / 5;
            int imgHeightDivided = imgHeight / 7;

            for (int i = 0; i < imgHeight; i += imgHeightDivided)
            {
                for (int j = 0; j < imgWidth; j += imgWidthDivided)
                {
                    PointsStartEnd buff = new PointsStartEnd();
                    if (j + imgWidthDivided <= imgWidth && i + imgHeightDivided <= imgHeight)
                    {
                        buff.strat = new System.Drawing.Point(j, i);
                        buff.end   = new System.Drawing.Point(j + imgWidthDivided - 1, i + imgHeightDivided - 1);
                        list.Add(buff);
                    }
                }
            }

            return(list);
        }