I'm looking to reshape an array of three 2x2 matrices, that is of shape (3,2,2) i.e.
a = np.array([[[a1,a2],[a3,a4]],
[[b1,b2],[b3,b4]],
[[c1,c2],[c3,c4]]])
to this array of shape (2,2,3):
[[[a1,b1,c1],[a2,b2,c2]],
[[a3,b3,c3],[a4,b4,c4]]])
The regular np.reshape(a, (2,2,3))
returns this array:
[[[a1, a2, a3],[a4, b1, b2]],
[[b3, b4, c1],[c2, c3, c4]]]
and np.reshape(a, (2,2,3), order = 'F')
brings this:
[[[a1, b3, c2],[c1, a2, b4]],
[[b1, c3, a4],[a3, b2, c4]]]
How can I reshape the initial array to get what I need?
This is in order to use with matplotlib.pyplot.imshow
where the three initial matrices correspond to the three colors 'RGB' and each of the elements is a float in the range [0,1]. So also if there's a better way to do it I would be happy to know.