Skip to content

Instantly share code, notes, and snippets.

@reox
Created May 20, 2021 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reox/56da25a6f0c41bc667296dc07f3482b6 to your computer and use it in GitHub Desktop.
Save reox/56da25a6f0c41bc667296dc07f3482b6 to your computer and use it in GitHub Desktop.
Query the faces of a cubical image in numpy
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