繁体   English   中英

JES-更改图像的红色量

[英]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循环中交换xy 例如

for x in range(0, getWidth(source)):
  for y in range(0, halfHeight):
     # Do stuff

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM