Skip to content

Instantly share code, notes, and snippets.

@dsantiago
Created March 12, 2021 21:26
Show Gist options
  • Save dsantiago/84fe526325f5f3befa591a17c15a2040 to your computer and use it in GitHub Desktop.
Save dsantiago/84fe526325f5f3befa591a17c15a2040 to your computer and use it in GitHub Desktop.
imgs = np.arange(36).reshape(9, 2, 2)
print(imgs)
"""
array([[[ 0, 1],
[ 2, 3]],
[[ 4, 5],
[ 6, 7]],
[[ 8, 9],
[10, 11]],
[[12, 13],
[14, 15]],
[[16, 17],
[18, 19]],
[[20, 21],
[22, 23]],
[[24, 25],
[26, 27]],
[[28, 29],
[30, 31]],
[[32, 33],
[34, 35]]])
"""
np.concatenate(imgs.transpose(0, 2, 1).reshape(3, -1, 2), axis=1).T
"""
array([[ 0, 1, 4, 5, 8, 9],
[ 2, 3, 6, 7, 10, 11],
[12, 13, 16, 17, 20, 21],
[14, 15, 18, 19, 22, 23],
[24, 25, 28, 29, 32, 33],
[26, 27, 30, 31, 34, 35]])
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment