好吧,这个标题是不言而喻的。我有一个图像文件,我想分别分为Y,Cb和Cr。打开文件后,将其从RGB(这是打开图像文件时的默认模式)转换为YCbCr,然后使用numpy.array()将其转换为数组,它生成了一个具有4个通道的二维数组,这不是我所期望的,如http://www.nmt.edu/tcc/help/pubs/pil/pil.pdf中的文档所示
以下是我在口译员中的工作:
ImageFile = Image.open('filePath', 'r')
ImageFile = ImageFile.convert('YCbCr')
ImageFileYCbCr = numpy.array(ImageFile)
ImageFileYCbCr
导致
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],
...,
当我把它分成不同的通道
ImageFileY = copy.deepcopy(ImageFileYCbCr) # to make a separate copy as array is immutable
ImageFileY[:,:,1] *= 0
ImageFileY[:,:,2] *= 0
ImageFileY[:,:,3] *= 0
ImageFileYOnly = Image.fromarray(ImageFileY)
ImageFileYOnly.show()
它产生了一个红色通道,就好像它是一个RGB。我怎样才能分别得到Y,Cb,Cr值?
编辑:Numpy version 1.3,Python 2.6linux回溯5
仅供参考,对于来自谷歌的未来人士:
现在似乎可以了。
作为参考,我有枕头6.1.0和numpy 1.17.0。做
给予相同的
与RGB不同。
https://mail.python.org/pipermail/image-sig/2010-October/006526.html
这是一只老虫子。纠正它
相关问题 更多 >
编程相关推荐