public static bool IsFullPage(Bitmap page, IEnumerable<IPolygon> polygons)
        {
            Grayscale gs = new Grayscale(0.30, 0.59, 0.11);
            Bitmap result = gs.Apply(page.To32bpp());
            long color = aggregateImageIntensity(result);

            return isWhite(color, page.Width * page.Height, 0.95) ||
                   isBlack(color, page.Width * page.Height, 0.6) ||
                   cellsCover(polygons) < 0.4 * page.Width * page.Height;
        }
 public static Bitmap Threshold(Bitmap page, int threshold)
 {
     page = page.To32bpp();
     Grayscale gs = new Grayscale(0.30, 0.59, 0.11);
     Threshold ts = new Threshold(threshold);
     Bitmap result = gs.Apply(page);
     return ts.Apply(result);
 }
Exemplo n.º 3
0
        private void CheckColors(HashSet<Color> testColors, Bitmap b)
        {
            bool result;
            b = b.To32bpp();
            BitmapData data = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            result = CheckColors(testColors, data);
            b.UnlockBits(data);

            Assert.IsTrue(result, "Required point missing");
        }