Well, the name is pretty clear. I have an image file that I want to split into Y, Cb and Cr respectively. After opening the file, convert it from RGB (which is the default mode when opening the image file) to YCbCr, and then turn it into an array using numpy.array (), the result is a two-dimensional array with 4 channels, which I did not expect, as according to the documentation at http://www.nmt.edu/tcc/help/pubs/pil/pil.pdf
Here is what I do in the translator:
ImageFile = Image.open('filePath', 'r') ImageFile = ImageFile.convert('YCbCr') ImageFileYCbCr = numpy.array(ImageFile) ImageFileYCbCr
Led to
array([[[103, 140, 133, 95], [140, 133, 91, 141], [132, 88, 141, 131], ..., [129, 65, 146, 129], [ 64, 146, 130, 65], [146, 129, 64, 147]], [[129, 64, 147, 129], [ 62, 149, 130, 62], [149, 130, 62, 149], ...,
And when I divide it into channels
ImageFileY = copy.deepcopy(ImageFileYCbCr)
This led to the appearance of a red channel, as if it were RGB. How can I get the values โโof Y, Cb, Cr, respectively?
UPDATE: Numpy version 1.3, Python 2.6 Linux Backtrack 5