Created
May 20, 2021 12:41
-
-
Save reox/56da25a6f0c41bc667296dc07f3482b6 to your computer and use it in GitHub Desktop.
Query the faces of a cubical image in numpy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# Numpy array is xyz | |
img = np.zeros((10,20,30)) | |
a = slice(None) # all items, same as ':' | |
faces = { | |
'top': (-1, a, a), | |
'bottom': (0, a, a), | |
'north': (a, -1, a), | |
'south': (a, 0, a), | |
'east': (a, a, -1), | |
'west': (a, a, 0), | |
} | |
for face, slic in faces.items(): | |
print(face, img[slic].shape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment