import Image
im=Image.open('c:/House24.png')
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.show(im)
import Image
im=Image.open('c:/House24.png')
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.show(im)
No comments:
Post a Comment