def change(pic, startX, startY, getHeight, getWidth, endColour):
width = getWidth
height = getHeight
picture = makePicture(pic)
for px in getPixels(picture):
x = getX(px)
y = getY(px)
if (startX <= x <= getHeight) and (startY <= y <= getWidth):
if (distance(black, getColor(px)) < 95):
setColor(px, endColour)
show (picture)
return (picture)
这是我到目前为止的代码。我需要做的是将照片中黑色像素的中间 1/3 更改为红色,将黑色像素的底部 1/3 更改为黄色,并在照片上打印更改为多少黑色像素黄色,有多少变成了红色。我对 JES 和 Jython 以及整体编程非常陌生,因此非常感谢您提供帮助!