0
我試圖創建在JES一個程序具有兩個功能,main()和addVignette(inputPic,暈影)的jython JES:添加暈影輪廓
的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"