Ниже приведено краткое объяснение ответа
# 1. Reshape Image as (height/8, 8, width/8,8)
print(rawimg.reshape(rawimg.shape[0]//8, 8, -1, 8).shape)
# 2. Swap 1 and 2nd index
print(rawimg.reshape(rawimg.shape[0]//8, 8, -1, 8).swapaxes(1,2).shape)
# 3. Reshape again (-1,8,8) with -1 being combined both (548*704) arrays of shape 8x8
print(rawimg.reshape(rawimg.shape[0]//8, 8, -1, 8).swapaxes(1,2).reshape(-1,8,8).shape)
(548, 8, 704, 8)
(548, 704, 8, 8)
(385792, 8, 8)