regionAverage static method
Color
regionAverage(
- Image image,
- int startY,
- int endY, {
- int step = 10,
})
Implementation
static Color regionAverage(img.Image image, int startY, int endY, {int step = 10}) {
int r = 0, g = 0, b = 0, count = 0;
for (int y = startY; y < endY; y += step) {
for (int x = 0; x < image.width; x += step) {
final p = image.getPixel(x, y);
r += p.r.toInt();
g += p.g.toInt();
b += p.b.toInt();
count++;
}
}
if (count == 0) {
return Colors.black;
}
return Color.fromARGB(255, r ~/ count, g ~/ count, b ~/ count);
}