views:

10

answers:

1

Hey there, I can't figure out how to make Jython realize that the pixel is either (0,0,0) or (255,255,255). Basically I'm just trying to convert all white pixels to black and vice versa. Here's what i have sofar :S

def changeBlackWhite(picture):
    for x in range(getWidth(picture)):
        for y in range(getHeight(picture)):
            px = getPixel(picture, x, y)
            pxRed = getRed(px)
            pxBlue = getBlue(px)
            pxGreen = getGreen(px)
            if pxRed == '255':
                if pxBlue == '255':
                    if pxGreen == '255':
                        setRed(px, 0)
                        setBlue(px, 0)
                        setGreen(px, 0)

Help?! :)

A: 

I don't know what library you use, but I think that getRed() will return integer, and not string. Instead:

if pxRed == '255':

try comparing to integer:

if pxRed == 255:
Michał Niklas