getWhiteBalance method
Return the average gray value of the image.
Implementation
dynamic getWhiteBalance({bool asDouble=false}) {
final len = data.length;
double r = 0.0;
double g = 0.0;
double b = 0.0;
var t = 1;
for (var i = 0; i < len; ++i) {
r += (getRed(data[i]) - r) / t;
g += (getGreen(data[i]) - g) / t;
b += (getBlue(data[i]) - b) / t;
++t;
}
double averageGray = (r + g + b) / 3.0;
return asDouble ? averageGray : averageGray.toInt();
}