Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. def two_tone(image: color1, color2) -> image:
  2.     """ The function calculates the average of red, green, blue components of the images
  3.    to determine its pixels brightness. If the average of the components brightness are from
  4.    0 to 127 it sets to color1, but if the average components are between 128 to 255
  5.    the color sets to color2.
  6.    """
  7.     if color1 == "gray":
  8.         color_chosen1 = create_color(128, 128, 128)
  9.     if color2 == "cyan":
  10.         color_chosen2 = create_color(0, 255, 255)
  11.    
  12.     for pixel in original_image:
  13.         x, y, (r, g, b) = pixel
  14.        
  15.     if ((r, g, b) / 3 <= 127):
  16.         set_color(two_tone_image, x, y, color_chosen1(r, g, b))
  17.     elif ((r, g, b) / 3 >= 127):
  18.         set_color(two_tone_image, x, y, color_chosen2(r, g, b))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement