我试图减少下半部分图像中的红色,我感到难过,这是我想出的代码,只是想知道是否有人可以指出为什么它不适合我?
=SUM(select rows),
答案 0 :(得分:0)
我相信我已经得到了答案,这会将图像下半部分的红色减少到原来的70%。
def decreaseRed(pict):
width=getWidth(pict)
height=getHeight(pict)
canvas=makeEmptyPicture(width,height)
for x in range(0, width):
for y in range(0, height):
pixel = getPixel(pict,x,y)
newRed = getRed(pixel)
newGreen = getGreen(pixel)
newBlue = getBlue(pixel)
newColor = makeColor(newRed,newGreen,newBlue)
pixelCanvas = getPixel(canvas,x,y)
setColor(pixelCanvas,newColor)
for y in range(height/2,height):
pixel = getPixel(pict,x,y)
newRed = getRed(pixel)*0.7
newGreen = getGreen(pixel)
newBlue = getBlue(pixel)
newColor = makeColor(newRed,newGreen,newBlue)
pixelCanvas = getPixel(canvas,x,y)
setColor(pixelCanvas,newColor)
return canvas
file=getMediaPath("test.jpg")
pict=makePicture(file)
show(decreaseRed(pict))