original_docstring:  Combines three single-colour images (red, green, and blue) into a final image.
      Written by Anthony Luo
      :param log: Determines whether or not to return a datalog
      :type log: Defaults to False, ie no log
      :return: returns logs as tuple if log
      >>> combine()
      >>> show(load_image('combined_image.png'))
      
docstring: Combines three single-colour images (red, green, and blue) into a final image.
  Written by Anthony Luo
docstring_tokens: Combines three single - colour images ( red green and blue ) into a final image . Written by Anthony Luo
code: def combine( log = False ):
      """ Combines three single-colour images (red, green, and blue) into a final image.
      Written by Anthony Luo
      :param log: Determines whether or not to return a datalog
      :type log: Defaults to False, ie no log
      :return: returns logs as tuple if log
      >>> combine()
      >>> show(load_image('combined_image.png'))
      """
      # loads images in
      r_img = load_image('red_channel.png')
      g_img = load_image('green_channel.png')
      b_img = load_image('blue_channel.png')
  
      # creates new image with hard dimensions.
      # TODO: create a way to dynamically assign height
      new_img = create_image(640, 480)
  
      # creates the different channels for RGB
      # TODO: figure out a way to store these in a numpy matrix?
      r_chan = []
      g_chan = []
      b_chan = []
      rgb = []
  
      for x, y, (r, g, b) in r_img:  # grabs r value
          r_chan.append(r)
  
      for x, y, (r, g, b) in g_img:  # grabs g value
          g_chan.append(g)
  
      for x, y, (r, g, b) in b_img:  # grabs b value
          b_chan.append(b)
  
      counter = 0
      if not log:  # checks whether or not we should be logging (once, instead of every time the loop runs)
          for x, y, (r, g, b) in new_img:
              colour = create_color(r_chan[counter], g_chan[counter], b_chan[counter])  # create colour from constituents
              set_color(new_img, x, y, colour)  # set colour
              counter += 1
  
          show(new_img)
          save_as(new_img, 'combined_image.png')  # save and show image
          show(load_image('combined_image.png'))
      else:  # this is the same as above, except it saves all the files.
          for x, y, (r, g, b) in new_img:
              colour = create_color(r_chan[counter], g_chan[counter], b_chan[counter])
              rgb.append(colour)
              set_color(new_img, x, y, colour)
              counter += 1
  
          save_as(new_img, 'combined_image.png')
          show(load_image('combined_image.png'))
          return (r_chan, g_chan, b_chan, rgb)
code_tokens: def combine ( log = False ) : r_img = load_image ( 'red_channel.png' ) g_img = load_image ( 'green_channel.png' ) b_img = load_image ( 'blue_channel.png' ) new_img = create_image ( 640 , 480 ) r_chan = [ ] g_chan = [ ] b_chan = [ ] rgb = [ ] for x , y , ( r , g , b ) in r_img : r_chan . append ( r ) for x , y , ( r , g , b ) in g_img : g_chan . append ( g ) for x , y , ( r , g , b ) in b_img : b_chan . append ( b ) counter = 0 if not log : for x , y , ( r , g , b ) in new_img : colour = create_color ( r_chan [ counter ] , g_chan [ counter ] , b_chan [ counter ] ) set_color ( new_img , x , y , colour ) counter += 1 show ( new_img ) save_as ( new_img , 'combined_image.png' ) show ( load_image ( 'combined_image.png' ) ) else : for x , y , ( r , g , b ) in new_img : colour = create_color ( r_chan [ counter ] , g_chan [ counter ] , b_chan [ counter ] ) rgb . append ( colour ) set_color ( new_img , x , y , colour ) counter += 1 save_as ( new_img , 'combined_image.png' ) show ( load_image ( 'combined_image.png' ) ) return ( r_chan , g_chan , b_chan , rgb )
short_docstring: Combines three single-colour images (red, green, and blue) into a final image.
short_docstring_tokens: Combines three single - colour images ( red green and blue ) into a final image .
comment: """ Combines three single-colour images (red, green, and blue) into a final image.
      Written by Anthony Luo
      :param log: Determines whether or not to return a datalog
      :type log: Defaults to False, ie no log
      :return: returns logs as tuple if log
      >>> combine()
      >>> show(load_image('combined_image.png'))
      """$SEP$# loads images in$SEP$# creates new image with hard dimensions.$SEP$# TODO: create a way to dynamically assign height$SEP$# creates the different channels for RGB$SEP$# TODO: figure out a way to store these in a numpy matrix?$SEP$# grabs r value$SEP$# grabs g value$SEP$# grabs b value$SEP$# checks whether or not we should be logging (once, instead of every time the loop runs)$SEP$# create colour from constituents$SEP$# set colour$SEP$# save and show image$SEP$# this is the same as above, except it saves all the files.