I have a 3D array of binary data. I want to project this to 3 2D images - side on, head on, birds eye.
I have written the code:
for x in range(data.shape[2]):
for y in range(data.shape[0]):
val = 0
for z in range(data.shape[1]):
if data[y][z][x] > 0:
val = 255
break
side[y][x] = val
But this is horrifically slow (75s!) for a ~700x300x300 matrix.
What is the fastest way of achieving this task?
EDIT:
To save the image, I have used:
sideImage = Image.fromarray(side)
sideImage.convert('RGB').save("sideImage.png")