【发布时间】:2020-04-13 22:37:52
【问题描述】:
我正在尝试改变颜色的强度以获得不同的彩色图像...
import PIL
from PIL import Image
from PIL import ImageEnhance
from PIL import ImageDraw
# read image and convert to RGB
image=Image.open("readonly/msi_recruitment.gif")
image=image.convert('RGB')
# build a list of 9 images which have different brightnesses
enhancer=ImageEnhance.Brightness(image)
images=[]
for i in range(1, 10):
images.append(enhancer.enhance(i/10))
# create a contact sheet from different brightnesses
first_image=images[0]
contact_sheet=PIL.Image.new(first_image.mode, (first_image.width*3,first_image.height*3))
x=0
y=0
for img in images:
# Lets paste the current image into the contact sheet
contact_sheet.paste(img, (x, y) )
# Now we update our X position. If it is going to be the width of the image, then we set it to 0
# and update Y as well to point to the next "line" of the contact sheet.
if x+first_image.width == contact_sheet.width:
x=0
y=y+first_image.height
else:
x=x+first_image.width
# resize and display the contact sheet
contact_sheet = contact_sheet.resize((int(contact_sheet.width/2),int(contact_sheet.height/2) ))
display(contact_sheet)
但上面的代码只是改变亮度.... 请告诉我应该进行哪些更改以更改此代码中的颜色强度..... 很抱歉,我现在无法上传图片,请考虑您认为合适的任何图片并帮助我...感谢!!!!
请转到此链接并回答这个问题而不是这个问题,对于给您带来的不便,我深表歉意......
【问题讨论】:
标签: python-3.x colors python-imaging-library