public static double[] AveragePixelColour(Bitmap image, RectangularRegion region) =>
 new double[]
 {
     MapRegions(region, (x, y) => image.GetPixel(x, y).R),
     MapRegions(region, (x, y) => image.GetPixel(x, y).G),
     MapRegions(region, (x, y) => image.GetPixel(x, y).B)
 };
 public static double MapRegions(RectangularRegion region, Func <int, int, byte> f) =>
 Enumerable.Range(region.X1, region.X2 + 1 - region.X1)
 .SelectMany(x =>
             Enumerable.Range(region.Y1, region.Y2 + 1 - region.Y1)
             .Select(y => (double)(f(x, y)))
             )
 .Average();