I'm have a line of code that efficiently reshapes a numpy array from a 400x8x8 array to a 160x160 array and I need to reverse the process but can't figure out the reverse of the line.
I can already do this process but it is very inefficient and requires nested loops which I would like to avoid for performance purposes.
Here is the code that I currently have to reverse the process (160x160 > 400x8x8):
previousRow = 0
for rowBlock in range(noBlocksOn1Axis):
previousRow = rowBlock * blockSize
previousColumn = 0
for columnBlock in range(noBlocksOn1Axis):
previousColumn = columnBlock * blockSize
block =
arrayY[previousRow:previousRow+blockSize,
previousColumn:previousColumn + blockSize]
blocksList.append(block)
And here is the line of code that reshapes 400x8x8 > 160x160:
xy = np.zeros((160,160), dtype = np.uint8)
xy = np.vstack(np.hstack(overDone[20*i:20+20*i]) for i in
range(overDone.shape[0]//20))
So any ideas of how I can perform this line of code in reverse?
Thanks :D