繁体   English   中英

简单的jes功能可以将图片的颜色从红色切换为绿色或蓝色?

[英]Simple jes Function to switch a pictures color from red to green or blue?

标题说明了一切,我只是在寻找一种简单的方法将所有照片的红色像素更改为绿色或蓝色。

假设您要交换每个像素的红色和蓝色值,那么这就是您的方法。 如果没有,这里应该有足够的空间让您接近。

def swapRedwithBlue(sourceImage):

width = getWidth(sourceImage)
height = getHeight(sourceImage)

for x in range(width):
  for y in range(height):

    sourcePixel = getPixel(sourceImage, x, y) 
    R = getRed(sourcePixel)
    G = getGreen(sourcePixel)
    B = getBlue(sourcePixel)
    color = makeColor(B, G, R)
    destinationPixel = getPixel(sourceImage, x, y)
    setColor(destinationPixel, color)

repaint(sourceImage)

暂无
暂无

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

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