예제 #1
0
 private static bool GuestimateBitFromArea(Bitmap bitmap, int x, int y)
 {
     BitValue[] areaBits = new BitValue[9];
     // get bits from surrounding area
     for (int i = -1; i <= 1; i++)
     {
         for (int j = -1; j <= 1; j++)
         {
             areaBits[(i + 1) * 3 + (j + 1)] = DetermineValueFromColor(bitmap.GetPixel(x + i, y + j));
         }
     }
     // determine mayority color
     return((areaBits.Count(bit => bit == BitValue.BRIGHT) >= areaBits.Count(bit => bit == BitValue.DARK)) ? false : true);
 }
예제 #2
0
 private static BitValue GuestimateValueFromArea(Bitmap bitmap, int x, int y)
 {
     BitValue[] areaBits = new BitValue[9];
     // get bits from surrounding area
     for (int i = -1; i <= 1; i++)
     {
         for (int j = -1; j <= 1; j++)
         {
             areaBits[(i + 1) * 3 + (j + 1)] = DetermineValueFromColor(bitmap.GetPixel(x + i, y + j));
         }
     }
     if ((Math.Abs(areaBits.Count(bit => bit == BitValue.BRIGHT) - areaBits.Count(bit => bit == BitValue.DARK)) <= 2) || (areaBits.Count(bit => bit == BitValue.UNKNOWN) >= 5))
     {
         return(BitValue.UNKNOWN);
     }
     return((areaBits.Count(bit => bit == BitValue.BRIGHT) >= areaBits.Count(bit => bit == BitValue.DARK)) ? BitValue.BRIGHT : BitValue.DARK);
 }