在Python错误消息中亮显和暗显图像

在Python错误消息中亮显和暗显图像,python,image,python-2.7,for-loop,graphics,Python,Image,Python 2.7,For Loop,Graphics,好的,所以我想要它,如果有人输入1,输入0到1之间的值,它会使图像变亮,如果有人输入2,输入0到1之间的值,它会使图像变暗,我想这个可行吗 这是我得到的方程式,为什么不起作用? 阴暗 如果像素P1=R1、G1、B1的值和所需的变化量是S不工作的,那么你会考虑使用NUMPY和MatPutTLIB吗?这对任何知道Python的人来说都是很容易的,这不应该那么难…你应该准确而清晰地写下不起作用的内容,最好显示不良结果的回溯或输出。。。 from graphics import* #Author: #P

好的,所以我想要它,如果有人输入1,输入0到1之间的值,它会使图像变亮,如果有人输入2,输入0到1之间的值,它会使图像变暗,我想这个可行吗

这是我得到的方程式,为什么不起作用? 阴暗
如果像素P1=R1、G1、B1的值和所需的变化量是S不工作的,那么你会考虑使用NUMPY和MatPutTLIB吗?这对任何知道Python的人来说都是很容易的,这不应该那么难…你应该准确而清晰地写下不起作用的内容,最好显示不良结果的回溯或输出。。。
from graphics import*
#Author:
#Purpose: to lighten and darken images
#filename: lab3.py

#Purpose: to get infromation from user and send to function
#inputs:none
#outputs: picture
def main():
    choice=raw_input('press 1 to light,2 to darken')
    value=raw_input('by how much: ')
    name=raw_input('Enter name of image: ')
    temp=Image(Point(0,0),name)
    width= temp.getWidth()
    height= temp.getHeight()
    pic = Image(Point(width/2,height/2),name) 
    win=GraphWin("Original",width, height)
    if choice=='1':
        s=1- float (value)
        grey2(name,choice,pic,s).draw(win)
    if choice=='2':
        s= float(value)
        grey1(name,choice,pic,s).draw(win)
#Purpose:to darken image
#inputs: name,choice,pic,s
#outputs: return newPic
def grey1(name, choice, pic,s):
    newPic=pic.clone()
    for i in range (newPic.getHeight()):#goes through every pixel
        for f in range (newPic.getWidth()): 
            g=newPic.getPixel(f,i)
            newPic.setPixel(f,i,color_rgb(g[0]*s,g[1]*s,g[2]*s))
    return newPic
#purpose: to lighten image
#inputs: name,choice,pic,s
#outputs: return newPIc
def grey2(name, choice, pic,s):
    newPic=pic.clone()
    for i in range (newPic.getHeight()):#goes through every pixel
        for f in range (newPic.getWidth()): 
            g=newPic.getPixel(f,i)
            newPic.setPixel(f,i,color_rgb(s*g[0]+(255*s),g[1]*s+(255*s),g[2]*s+(255*s)))
    return newPic


main()
Tint (lighten) 
If the value of pixel p1 = (r1, g1, b1) and the amount of desired change is t (<= 1.0) 
Then the value of the new pixel, p2 = 
r2 = (t * r1) + (255 * (1.0 - t)) 
g2 = (t * g1) + (255 * (1.0 - t)) 
b2 = (t * b1) + (255 * (1.0 - t))