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!
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!
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]]