I'm still new to numpy
and having trouble writing a lambda to do what I want in this case. It could be that the lambda is not working because of the data in the array?
I've got some pixel values from a QImage
in Qt5 using PyQT
in Python:
ptr = self.myPhoto.bits()
ptr.setsize(self.myPhoto.byteCount())
pixels = np.asarray(ptr).reshape(self.myPhoto.height(), self.myPhoto.width(), 4)
The pixel data looks like this [[[B G R A]]]:
[[[ 100 0 2 255]
[ 100 0 2 255]
[ 100 1 1 255]
...,
[ 2 3 0 255]
[ 1 2 0 255]
[ 1 2 0 255]]]
I want it to look like this [[[R G B A]]]:
[[[ 2 0 100 255]
[ 2 0 100 255]
[ 1 1 100 255]
...,
[ 0 3 2 255]
[ 0 2 1 255]
[ 0 2 1 255]]]
EDIT: removed commas from array
Also, is it possible to do this right from reshape call instead of using a lambda post process?
These questions are interesting, but I'm still having trouble glueing them together to get what I want: