我需要在图像的上半部分将像素中的红色减少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轴。我尝试到处寻找解决方案,但似乎找不到anything...Help。
发布于 2014-11-21 12:00:37
您所需要做的就是交换x和y中的for循环。例如
for x in range(0, getWidth(source)):
for y in range(0, halfHeight):
# Do stuffhttps://stackoverflow.com/questions/27030006
复制相似问题