Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def two_tone(image: color1, color2) -> image:
- """ The function calculates the average of red, green, blue components of the images
- to determine its pixels brightness. If the average of the components brightness are from
- 0 to 127 it sets to color1, but if the average components are between 128 to 255
- the color sets to color2.
- """
- if color1 == "gray":
- color_chosen1 = create_color(128, 128, 128)
- if color2 == "cyan":
- color_chosen2 = create_color(0, 255, 255)
- for pixel in original_image:
- x, y, (r, g, b) = pixel
- if ((r, g, b) / 3 <= 127):
- set_color(two_tone_image, x, y, color_chosen1(r, g, b))
- elif ((r, g, b) / 3 >= 127):
- set_color(two_tone_image, x, y, color_chosen2(r, g, b))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement