0

I have an array shape =(64, 64,64) I want to divide it in 8 blocks like the image, each array shape would be then (32,32,32). How do I achieve this?

octant box splitting

2 Answers 2

1

You might reshape your array as follows:

import numpy as np
a = np.random.randn(64, 64, 64)
b = a.reshape((-1, 32, 32, 32))

You'll then see b.shape being equal to (8, 32, 32, 32).

Sign up to request clarification or add additional context in comments.

Comments

0

Check out numpy´s slicing:

import numpy as np

x = np.random.rand(64,64,64)

x_block_1 = x[32:64,32:64,32:64]
x_block_2 = x[0:32,32:64,32:64]
...
x_block_2 = x[32:64,0:32,0:32]

This is according to your definition.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.