private static double GetPercentWhiteOfLine(Bitmap bmp, int lineNumber)
{
if(lineNumber >= bmp.Height)
return 0; //guard against math errors by the caller
const int maxCombinedRgbValueToBeConsideredWhite = 3 * 253; // true white is 255. We'll count off-white as well
int whiteCount=0;
for (int x = 0; x < bmp.Width; x++)
{
var pixelColor = bmp.GetPixel(x, lineNumber);
//we'll add up the R, G, and B
if ((pixelColor.R + pixelColor.G + pixelColor.B) > maxCombinedRgbValueToBeConsideredWhite)
++whiteCount;
}
return ((double)whiteCount)/(double)bmp.Width;
}