Joseph Drackey

Generation

generate functionWed, 29 Mar 2023

Define a function named posterize. This function expects an image and a tuple of RGB values as arguments.

def posterize(image, tup): for row in range(image.height): for col in range(image.width): p = image.getPixel(col, row) newRed = tup[0] newGreen = tup[1] newBlue = tup[2] newpixel = image.Pixel(newRed, newGreen, newBlue) image.setPixel(col, row, newpixel) return image posterize(image, (255, 0, 0))

Questions about programming?Chat with your personal AI assistant