Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
When I print my 5x5x3 numpy array, it prints as 5 5x3 arrays.
I have read in a 5 pixel x 5 pixel rgb image and want to view the 5x5 arrays that are R, G and B. How do I do this?
Thanks!
for plane in np.rollaxis(matrix, -1): print(plane)
print(np.rollaxis(matrix, -1))
Something like this should work:
In [1]: import numpy as np In [2]: a = np.array([[[1,2,3], [3,4,3]],[[5,6,3], [7,8,3]]]) In [3]: a.shape Out[4]: (2, 2, 3) In [4]: for i in range(a.shape[-1]): ...: print(a[:,:,i]) ...: [[1 3] [5 7]] [[2 4] [6 8]] [[3 3] [3 3]]
Add a comment
Required, but never shown
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.
Explore related questions
See similar questions with these tags.
for plane in np.rollaxis(matrix, -1): print(plane). Or even justprint(np.rollaxis(matrix, -1))