original_docstring:  image is 2 x Ly x Lx or Ly x Lx x 2 - change to RGB Ly x Lx x 3 
docstring: image is 2 x Ly x Lx or Ly x Lx x 2 - change to RGB Ly x Lx x 3
docstring_tokens: image is 2 x Ly x Lx or Ly x Lx x 2 - change to RGB Ly x Lx x 3
code: def image_to_rgb(img0, channels=[0,0]):
      """ image is 2 x Ly x Lx or Ly x Lx x 2 - change to RGB Ly x Lx x 3 """
      img = img0.copy()
      img = img.astype(np.float32)
      if img.ndim<3:
          img = img[:,:,np.newaxis]
      if img.shape[0]<5:
          img = np.transpose(img, (1,2,0))
      if channels[0]==0:
          img = img.mean(axis=-1)[:,:,np.newaxis]
      for i in range(img.shape[-1]):
          if np.ptp(img[:,:,i])>0:
              img[:,:,i] = utils.normalize99(img[:,:,i])
              img[:,:,i] = np.clip(img[:,:,i], 0, 1)
      img *= 255
      img = np.uint8(img)
      RGB = np.zeros((img.shape[0], img.shape[1], 3), np.uint8)
      if img.shape[-1]==1:
          RGB = np.tile(img,(1,1,3))
      else:
          RGB[:,:,channels[0]-1] = img[:,:,0]
          if channels[1] > 0:
              RGB[:,:,channels[1]-1] = img[:,:,1]
      return RGB
code_tokens: def image_to_rgb ( img0 , channels = [ 0 , 0 ] ) : img = img0 . copy ( ) img = img . astype ( np . float32 ) if img . ndim < 3 : img = img [ : , : , np . newaxis ] if img . shape [ 0 ] < 5 : img = np . transpose ( img , ( 1 , 2 , 0 ) ) if channels [ 0 ] == 0 : img = img . mean ( axis = - 1 ) [ : , : , np . newaxis ] for i in range ( img . shape [ - 1 ] ) : if np . ptp ( img [ : , : , i ] ) > 0 : img [ : , : , i ] = utils . normalize99 ( img [ : , : , i ] ) img [ : , : , i ] = np . clip ( img [ : , : , i ] , 0 , 1 ) img *= 255 img = np . uint8 ( img ) RGB = np . zeros ( ( img . shape [ 0 ] , img . shape [ 1 ] , 3 ) , np . uint8 ) if img . shape [ - 1 ] == 1 : RGB = np . tile ( img , ( 1 , 1 , 3 ) ) else : RGB [ : , : , channels [ 0 ] - 1 ] = img [ : , : , 0 ] if channels [ 1 ] > 0 : RGB [ : , : , channels [ 1 ] - 1 ] = img [ : , : , 1 ] return RGB
short_docstring: image is 2 x Ly x Lx or Ly x Lx x 2 - change to RGB Ly x Lx x 3
short_docstring_tokens: image is 2 x Ly x Lx or Ly x Lx x 2 - change to RGB Ly x Lx x 3
comment: """ image is 2 x Ly x Lx or Ly x Lx x 2 - change to RGB Ly x Lx x 3 """