I'm doing some image processing in Python using PIL, I need to extract the luminance layer from a series of images, and do some processing on that using numpy, then put the edited luminance layer back into the image and save it. The problem is, I can't seem to get any meaningful representation of my Image in a YCbCr format, or at least I don't understand what PIL is giving me in YCbCr. PIL documentation claims YCbCr format gives three channels, but when I grab the data out of the image using np.asarray, I get 4 channels. Ok, so I figure one must be alpha.
Here is some code I'm using to test this process:
I'm expecting a greyscale version of my image, but what I get is this jumbled up mess:
Function list EDIUS means more formats and more resolutions in real-time for the ability to Edit Anything, Fast. EDIUS is the 4K HDR perfect finishing tool for professional productions, including documentary and theatrical productions.
Can anybody explain to me where I'm going wrong? The same code in matlab works exactly as I expect.
daverdaver
2 Answers
Since YCbCr is a simple, mathematically determinate conversion from RGB colorspace, going through the intermediate stage of YCbCr is just an indirect way of pulling a computed (not absolute) luminance value from an image. You can accomplish the same, more directly with:
I suspect that there is a problem with your conversion via numpy asarray or fromarray or in your numpy code because the sequence:
All works as expected. Incidentally,
Gives me three channels, not four.
mswmsw
If you convert the image to a numpy array like this, the problem should be solved:
I found it here.
RezaReza