from PIL import Image
band2 = Image.open('band2.tif')
band3 = Image.open('band3.tif')
band4 = Image.open('band4.tif')
img = Image.merge("RGB",(band4,band3,band2))
band2.tif,band3.tif,band4.tif在USGS(https://earthexplorer.usgs.gov/)下载。 与正常的.TIF
相比,它们可能有一些不同错误信息
/usr/bin/python3.5 /home/lixingang/workspace/20170405/main.py
Traceback (most recent call last):
File "/home/lixingang/workspace/20170405/main.py", line 5, in <module>
img = Image.merge("RGB",(band4,band3,band2))
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2388, in merge
raise ValueError("mode mismatch")
ValueError: mode mismatch
Process finished with exit code 1
答案 0 :(得分:0)
您需要将每个频道转换为亮度频道。所以不要这样:
band2 = Image.open('band2.tif')
你需要这样做:
band2 = Image.open('band2.tif').convert('L')
与其他渠道相同,对于合并订单也应予以考虑。