我正在尝试在 JES 中创建一个具有两个函数 main() 和 addVignette(inputPic, vignette) 的程序
main() 函数是创建两个图片对象的地方。我希望它允许用户选择输入图片(要操作的图片)然后允许用户选择小插图(vignette_profile.jpg)。创建这两个图片对象后,它应该调用 addVignette(inputPic, vignette)。
应编写 addVignette(inputPic, vignette) 函数以接受两个图片对象作为参数。这些图片对象是在 main() 函数中创建的,并作为输入传递给该函数。所以基本上,使用这两个图片对象,我需要我的函数来执行晕影添加操作,并且这个操作应该应用于 inputPic 图片中的每个像素。新编辑的图片应显示在屏幕上。
我无法将图片相乘。我不确定编码是否错误或我的方程式不正确。我不知道要准确编码什么,因为晕影轮廓具有较暗的边缘和较亮的中心。
多谢你们!
def main():
file1 = pickAFile()
file2 = pickAFile()
inputPic=makePicture(file1)
vignette=makePicture(file2)
addVignette(inputPic,vignette)
def addVignette(inputPic,vignette):
if getWidth(inputPic)==getWidth(vignette) and getHeight(inputPic)==getHeight(vignette):
explore(inputPic)
explore(vignette)
allpx=getAllPixels(inputPic)
for px in getAllPixels(inputPic):
x=getX(px)
y=getY(px)
px2=getPixelAt(vignette,x,y)
x1=getX(px)
y2=getY(px)
r1=getRed(px)
r2=getRed(px2)
g1=getGreen(px)
g2=getGreen(px2)
b1=getBlue(px)
b2=getBlue(px2)
if (1<r2<137):
r3=(r2-r1)-33
g3=(g2-g1)+21
b3=(b1-b2)+51
if (138<r2<210):
r3=(r2-r1)-21
g3=(g2-g1)+49
b3=(b1-b2)+121
if (211<r2<246):
r3=(r2-r1)+66
g3=(g2-g1)+138
b3=(b1-b2)+177
if (247<r2<255):
r3=(r2-r1)+44
g3=(g2-g1)+125
b3=(b2-b1)+201
setRed(px,r3)
setGreen(px,g3)
setBlue(px,b)
explore(inputPic)
else:
print "Try Again"