original_docstring:  Saves a new image which constitutes only the red channel of an image img
      Written by Anthony Luo
      :param img: Original image
      :type img: Image
      :param verify: Whether or not to verify the image (ie, show it to the user)
      :type verify: bool
      :param log: whether or not to save image data to log files
      :type log: bool
      :return: None
      :rtype: NoneType
      >>> image = load_image(choose_image())
      >>> createRed(image)
      >>> show(image)
      
docstring: Saves a new image which constitutes only the red channel of an image img
  Written by Anthony Luo
docstring_tokens: Saves a new image which constitutes only the red channel of an image img Written by Anthony Luo
code: def create_red( img: Image, verify: bool = True, log: bool = False ):
      """ Saves a new image which constitutes only the red channel of an image img
      Written by Anthony Luo
      :param img: Original image
      :type img: Image
      :param verify: Whether or not to verify the image (ie, show it to the user)
      :type verify: bool
      :param log: whether or not to save image data to log files
      :type log: bool
      :return: None
      :rtype: NoneType
      >>> image = load_image(choose_image())
      >>> createRed(image)
      >>> show(image)
      """
      image = copy(img)
      if verify:
          show(image)  # shows the original image
  
      # checks if you are logging or not (once, at the start, instead of everytime)
      if log:
          try:
              os.remove('redImgLog.txt')
          except:
              pass
          red_log = open('redImgLog.txt', 'a')  # creates a NEW log file
          for x, y, (r, g, b) in image:  # reads through the image pixel by pixel
              red = create_color(r, 0, 0)  # creates new 'colour' tuple
  
              # remaps each x,y coordinate to new colour
              set_color(image, x, y, red)
          str1 = f'{x:03}' + f'{y:03}' + f'{r:03}' + f'{g:03}' + f'{b:03}' + f'{red[0]:03}' + \
                 f'{red[1]:03}' + f'{red[2]:03}' + '\n'  # creates logger string
          red_log.write(str1)  # saves string
      else:
          for x, y, (r, g, b) in image:  # reads through the image pixel by pixel
              red = create_color(r, 0, 0)  # creates new 'colour' tuple
  
              # remaps each x,y coordinate to new colour
              set_color(image, x, y, red)
  
      save_as(image, 'red_channel.png')  # saves as a new image
      if verify:
          show(load_image('red_channel.png'))  # shows the image to double check
  
      print('red_channel created')
code_tokens: def create_red ( img : Image , verify : bool = True , log : bool = False ) : image = copy ( img ) if verify : show ( image ) if log : try : os . remove ( 'redImgLog.txt' ) except : pass red_log = open ( 'redImgLog.txt' , 'a' ) for x , y , ( r , g , b ) in image : red = create_color ( r , 0 , 0 ) set_color ( image , x , y , red ) str1 = f'{x:03}' + f'{y:03}' + f'{r:03}' + f'{g:03}' + f'{b:03}' + f'{red[0]:03}' + f'{red[1]:03}' + f'{red[2]:03}' + '\n' red_log . write ( str1 ) else : for x , y , ( r , g , b ) in image : red = create_color ( r , 0 , 0 ) set_color ( image , x , y , red ) save_as ( image , 'red_channel.png' ) if verify : show ( load_image ( 'red_channel.png' ) ) print ( 'red_channel created' )
short_docstring: Saves a new image which constitutes only the red channel of an image img
  Written by Anthony Luo
short_docstring_tokens: Saves a new image which constitutes only the red channel of an image img Written by Anthony Luo
comment: """ Saves a new image which constitutes only the red channel of an image img
      Written by Anthony Luo
      :param img: Original image
      :type img: Image
      :param verify: Whether or not to verify the image (ie, show it to the user)
      :type verify: bool
      :param log: whether or not to save image data to log files
      :type log: bool
      :return: None
      :rtype: NoneType
      >>> image = load_image(choose_image())
      >>> createRed(image)
      >>> show(image)
      """$SEP$# shows the original image$SEP$# checks if you are logging or not (once, at the start, instead of everytime)$SEP$# creates a NEW log file$SEP$# reads through the image pixel by pixel$SEP$# creates new 'colour' tuple$SEP$# remaps each x,y coordinate to new colour$SEP$# creates logger string$SEP$# saves string$SEP$# reads through the image pixel by pixel$SEP$# creates new 'colour' tuple$SEP$# remaps each x,y coordinate to new colour$SEP$# saves as a new image$SEP$# shows the image to double check