Exemple #1
0
        private static object GetInterior(BackgroundValue bp, IEnumerable <Bitmap> positives)
        {
            //Get the actual pattern
            Bitmap pattern = null;

            switch (bp.Type)
            {
            case "single":
                pattern = MostFrequentPixel(bp, positives);
                break;

            case "horizontal":
                pattern = MostFrequentColumn(bp, positives);
                break;

            case "vertical":
                pattern = MostFrequentRow(bp, positives);
                break;
            }

            if (pattern == null)
            {
                return(null);
            }

            //Get the matching strategy and what was missed
            string matcher = null;
            int    missed  = 0;

            switch (bp.Type)
            {
            case "single":
            case "horizontal":
                matcher = "horizontal";
                foreach (Bitmap bmp in positives)
                {
                    missed += HorizontalPatternMatcher.Missed(pattern, bmp, bp);
                }
                break;

            case "vertical":
                matcher = "vertical";
                foreach (Bitmap bmp in positives)
                {
                    missed += VerticalPatternMatcher.Missed(pattern, bmp, bp);
                }
                break;
            }

            BackgroundResults results = new BackgroundResults();

            results.Region = new Region(matcher, pattern);
            results.Missed = missed;
            return(results);
        }
Exemple #2
0
        private static Region GetHorizontal(bool top, int left, int right, int height, IEnumerable <Bitmap> positives)
        {
            Bitmap prev = null;

            foreach (Bitmap example in positives)
            {
                int toploc = 0;
                if (!top)
                {
                    toploc = example.Height - height;
                }

                Bitmap pattern = HorizontalPatternMatcher.ShortestPattern(example, toploc, left, example.Width - right - 1, height);
                if (prev != null && !prev.Equals(pattern))
                {
                    return(null);
                }

                prev = pattern;
            }

            return(new Region("horizontal", prev));
        }