Example #1
0
        private bool isBlackWhite(Color[,] image, CIELAB[,] imageLAB)
        {
            double nonGray = 0;
            double thresh  = 0.001;
            CIELAB white   = new CIELAB(100, 0, 0);
            CIELAB black   = new CIELAB(0, 0, 0);

            int width  = image.GetLength(0);
            int height = image.GetLength(1);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    Color  color = image[i, j];
                    CIELAB lab   = imageLAB[i, j];//Util.RGBtoLAB(color);
                    bool   gray  = color.GetSaturation() <= 0.2 || lab.SqDist(white) <= 5 || lab.SqDist(black) <= 5;

                    if (!gray)
                    {
                        nonGray++;
                    }
                }
            }
            return(nonGray / (width * height) < thresh);
        }