Код: Выделить всё
for row in range(0, height, 2):
for col in range(0, width, 2):
# Each pixel in the result image use the the average
# colour of the 2x2 pixels from the original image
# (i.e. the pixel itself in row,col and pixels in
# row,col+1 -- row+1,col -- row+1, col+1
sumR = 0
sumG = 0
sumB = 0
for r in range(row, row+2): # r will be row and row+1
for c in range(col, col+2): # c will be col and col+1
sumR += img[r][c][0]
sumG += img[r][c][1]
sumB += img[r][c][2]
Подробнее здесь: https://stackoverflow.com/questions/792 ... -for-loops