title: How to merge 2 channel of optical flow grayscale JPG images into one RGB image in Python?
body: <p>I'm making a RGB image from the given 2 grayscale jpg images, which is for x, y channel in optical flow respectively.</p>
  
  <p><a href="https://i.stack.imgur.com/8T1dI.jpg" rel="nofollow noreferrer">sample input images and my current output</a></p>
  
  <pre><code>def optical_flow(one, two, w, h):
      """
      method taken from (https://chatbotslife.com/autonomous-vehicle-speed-estimation-from-dashboard-cam-ca96c24120e4)
      """
      one_g = cv2.cvtColor(one, cv2.COLOR_RGB2GRAY)
      two_g = cv2.cvtColor(two, cv2.COLOR_RGB2GRAY)
      hsv = np.zeros((w, h, 3))
      # set saturation
      hsv[:,:,1] = cv2.cvtColor(two, cv2.COLOR_RGB2HSV)[:,:,1]
      # obtain dense optical flow paramters
      flow = cv2.calcOpticalFlowFarneback(one_g, two_g, flow=None,
                                          pyr_scale=0.5, levels=1, winsize=15,
                                          iterations=2,
                                          poly_n=5, poly_sigma=1.1, flags=0)
      # convert from cartesian to polar
      mag, ang = cv2.cartToPolar(flow[..., 0], flow[..., 1])
      # hue corresponds to direction
      hsv[:,:,0] = ang * (180/ np.pi / 2)
      # value corresponds to magnitude
      hsv[:,:,2] = cv2.normalize(mag,None,0,255,cv2.NORM_MINMAX)
      # convert HSV to int32's
      hsv = np.asarray(hsv, dtype= np.float32)
      rgb_flow = cv2.cvtColor(hsv,cv2.COLOR_HSV2RGB)
      return rgb_flow 
  
  imgu = cv2.imread('u.jpg')
  imgv = cv2.imread('v.jpg')
  img = optical_flow(one, two, w, h)
  
  Image.fromarray(imgu, 'RGB').show() // top-left one in img
  Image.fromarray(imgv, 'RGB').show() // top-right one in img
  Image.fromarray(img, 'RGB').show()  // bottom-left one in img
  </code></pre>
  
  <p>I think the output image looks strange. </p>