[英]JES - Alter the amount of red of an image
我需要在圖像的上半部分將像素中的紅色減少50%,然后將下半部分增加50%
def changeRed():
setMediaPath("/Users/addison/Downloads/Cmpt101_Pics/Learjet31A.jpg")
filename1 = "/Users/addison/Downloads/Cmpt101_Pics/Learjet31A.jpg"
source = makePicture(filename1)
halfWidth = getWidth(source)/2
for y in range(0,getHeight(source)):
for x in range(0, halfWidth):
pixel = getPixel(source, x, y)
value = getRed(pixel)
setRed(pixel, value-127.5)
show(source)
這就是我現在所擁有的,我不確定如何更改它以使其在X軸上而不是目前在Y軸上減半。我試圖在各處尋找解決方案,但可以似乎找不到任何東西...請幫助
您需要做的就是在for
循環中交換x
和y
。 例如
for x in range(0, getWidth(source)):
for y in range(0, halfHeight):
# Do stuff
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.