1for(size_t bx = 0; bx < width; bx += block_width)
2for(size_t by = 0; by < height; by += block_height) {
3 float sum = 0;
4 for(size_t x = 0; x < block_width; ++x)
5 for(size_t y = 0; y < block_height; ++y) {
6 sum += array[bx + x][by + y];
7 }
8 average = sum / (block_width * block_height);
9 new_array[bx][by] = average;
10}