Since YCbCr is a simple , mathematically determined conversion from the RGB color space, passing through the intermediate stage of YCbCr is just an indirect way to derive the calculated (not absolute) brightness value from the image. You can accomplish the same thing more directly with:
yIm = pengIm.convert('L')
I suspect there is a problem with converting via numpy asarray or fromarray or to your numpy code, because the sequence is:
>>> import Image >>> import ImageOps >>> import ImageChops >>> c = Image.open('squished_levels.png') >>> c <PngImagePlugin.PngImageFile image mode=RGB size=320x240 at 0xB7686DAC> >>> c.getbands() ('R', 'G', 'B') >>> d = c.convert('L') >>> d.getextrema()
Everything works as expected. By the way
>>> h = c.convert('YCbCr') >>> h <Image.Image image mode=YCbCr size=320x240 at 0xB761378C> >>> h.getpixel((0,0)) (119, 127, 128) >>> h.getbands() ('Y', 'Cb', 'Cr')
Gives me three channels, not four.
source share