Im pretty new to python. I have a np array (image) of size (128x128) and I want to divide it into 64 patches of 16x16. how can I slice the array? and How can I reassemble it into a 128x128 array afterwards?
I tried this but it's adding memory expense when I try to reassemble it
import numpy as np
xpx = np.random.rand(5,128,128)
new=np.zeros((5,64,16,16))
for i in range(0,5):
w=0
for j in range(0,128,16):
for k in range(0,128,16):
new[i,w]=xpx[i,j:j+16,k:k+16]
w=w+1