Skip to content
Advertisement

How to take n block of a 3d array in python?

I had 328 grayscale images with the size 128*128 and I convert all of them into a 3D array with the shape (128,128,328). Now I want to convert it into 5 separated 3d arrays with the shape of (128,128,64) without changing in sequence.

enter image description here

As you can see 328 is not divisible by 64 and using dsplit function is not working.

Is there any way to slice the 3d array on depth axes dynamically?

Advertisement

Answer

JavaScript

Output:

JavaScript

EDIT: Here is the same thing written in a dynamic way.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement