Пример #1
0
        private Line nextLine(IOIOMatrix image, int numAttempts, Point startPoint)
        {
            Line   bestLine     = new Line(Point.Empty, Point.Empty);
            double bestScore    = double.NegativeInfinity;
            double bestAvgCover = double.NegativeInfinity;

            for (int i = 0; i < numAttempts; ++i)
            {
                Line line = generateRandomLine(image.Width, image.Height, startPoint);

                double score    = image.Average(line);
                double avgCover = score / line.Length;

                if (UseIOIO2)
                {
                    if (avgCover > bestAvgCover * 0.95 && score > bestScore)
                    {
                        bestScore    = score;
                        bestAvgCover = avgCover;
                        bestLine     = line;
                    }
                }
                else
                {
                    if (score > bestScore)
                    {
                        bestScore    = score;
                        bestAvgCover = avgCover;
                        bestLine     = line;
                    }
                }
            }
            image.Subtract(bestLine, GRAY_RESOLUTION);
            return(bestLine);
        }