0
我從PIL手冊獲得了這段代碼,但是我收到一條錯誤消息。Python:PIL-Module中的Colorbands
from PIL import Image, ImageEnhance, ImageChops
im = Image.open("D:\\Python26\\PYTHON-PROGRAMME\\bild.jpg")
# split the image into individual bands
source = im.split()
R, G, B = 0, 1, 2
# select regions where red is less than 100
mask = source[R].point(lambda i: i < 100 and 255)
# process the green band
out = source[G].point(lambda i: i * 0.7)
# paste the processed band back, but only where red was < 100
source[G].paste(out, None, mask)
# build a new multiband image
im = Image.merge(im.mode, source)
im = im.point(lambda i: expression and 255)
im.save("D:\\Python26\\PYTHON-PROGRAMME\\bild2.jpg")
print('done')
錯誤:
Traceback (most recent call last):
File "D:\Python26\PYTHON-PROGRAMME\00000000000000000", line 14, in <module>
out = source[G].point(lambda i: i * 0.7)
IndexError: tuple index out of range
由於未定義'表達式',打印的腳本將不起作用。 – hop 2009-12-31 13:29:37
該問題必須與您的映像或您的安裝相關。我看不到這個代碼有問題。你確定你向我們展示了產生異常的完全相同的東西嗎? – hop 2009-12-31 13:31:39