首页 > 解决方案 > 像素颜色强度

问题描述

这张拼贴画是我应该得到的...... 目标图像

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.xpython-imaging-library

解决方案


推荐阅读