SHARE
TWEET

Untitled

a guest Nov 16th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top