I have a 3-D array in numpy, of dimensions 3000 x 2000 x 8
I need to modify the cells of the array so that each cell will contain the sum of all cells above and left of it, inclusive the current cell.
I am doing it using loops like below, but it is taking around 5 minutes to complete the program run. Is there a faster way in Python to achieve this (preferably without a loop)?
for depth in range(simg.shape[2]):
for row in range(1,simg.shape[0]-1):
for col in range(1,simg.shape[1]-1):
simg[row,col,depth]=simg[row-1,col,depth]+simg[row,col-1,depth]+simg[row,col,depth]-simg[row-1,col-1,depth]