bac*_*chr 8 python python-imaging-library rgba python-3.x
我有多个 PNG 图像文件,每个通道一个:红色、绿色、蓝色和黄色。
我如何将它们合并到一个 RBGA 图像中?
到目前为止我尝试了以下方法
from PIL import Image
red = Image.open('red.png')
green = Image.open('green.png')
blue = Image.open('blue.png')
yellow = Image.open('yellow.png')
rgb = Image.new('RGB', (blue.width, blue.height))
for im in [red, green, blue, yellow]:
rgb.paste(im, (0, 0))
rgb
Run Code Online (Sandbox Code Playgroud)
显然它不起作用,因为我只是覆盖了以前的图像。有任何想法吗?
更新:由于下面的评论,事实证明我可以将红色、绿色和蓝色文件合并为:
rgb = Image.merge("RGB",(red,green,blue))
Run Code Online (Sandbox Code Playgroud)
现在的问题是我如何使用黄色文件?
| 归档时间: |
|
| 查看次数: |
6633 次 |
| 最近记录: |