-2

I followed the process here: How to Split Image Into Multiple Pieces in Python for splitting an image into MxN number of images. I have a 5490x5490 that I split into 100 pieces by using the following:

M = im.shape[0]//10
N = im.shape[1]//10
tiles = [im[x:x+M,y:y+N] for x in range(0,im.shape[0],M) for y in range(0,im.shape[1],N)]

The shape of tiles is:

np.array(tiles).shape
(100,549,549)

I cannot figure out how to put them back together as one and reshape does not put them back together in the right order.

Thomas
  • 141
  • 1
  • 6

1 Answers1

0

Found it after taking a break: How to mosaic arrays using numpy?

nd_arr = np.array(tiles)
nd_arr = nd_arr.reshape(10, 10, 549, 549)
nd_arr = nd_arr.swapaxes(1,2)
final = nd_arr.reshape(5490, 5490)

I can verify by:

(final == NDVI).sum()
30140100
Thomas
  • 141
  • 1
  • 6