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); }
private static Region GetVertical(bool left, int top, int bottom, int width, IEnumerable <Bitmap> positives) { Bitmap prev = null; foreach (Bitmap example in positives) { int leftloc = 0; if (!left) { leftloc = example.Width - width; } Bitmap pattern = VerticalPatternMatcher.ShortestPattern(example, leftloc, top, example.Height - bottom - 1, width); if (prev != null && !prev.Equals(pattern)) { return(null); } prev = pattern; } return(new Region("vertical", prev)); }