how_color() missing 1 required positional argument: 'color' code example
Example: how_color() missing 1 required positional argument: 'color'
from images import Image
def posterize(image,rgb):
whitePixel = (255,255,255)
for y in range(image.getHeight()):
for x in range(image.getWidth()):
(nr, ng, nb) = image.getPixel(x,y)
average = (nr + ng + nb)/3
if average < 128:
image.setPixel((x,y),rgb)
else:
image.setPixel((x,y),whitePixel)
def main():
filename = input("Enter the image file name: ")
red = int(input("Enter an integer [0..255] for red: "))
green = int(input("Enter an integer [0..255] for green: "))
blue = int(input("Enter an integer [0..255] for blue: "))
image = Image(filename)
posterize(image, (red, green, blue))
image.draw()
if __name__ == "__main__":
main()