title: Visualize with OpenCV image read by tensorflow
body: <p>With the code below I read the same image with OpenCV and with Tensorflow.</p>
  <pre><code>import tensorflow as tf
  import cv2
  
  def get_image(image_path):
      &quot;&quot;&quot;Reads the jpg image from image_path.
      Returns the image as a tf.float32 tensor
      Args:
          image_path: tf.string tensor
      Reuturn:
          the decoded jpeg image casted to float32
      &quot;&quot;&quot;
      return tf.image.convert_image_dtype(
          tf.image.decode_jpeg(
              tf.read_file(image_path), channels=3),
          dtype=tf.uint8)
  
  
  path = &quot;./images/2010_006748.jpg&quot;
  original_image = cv2.imread(path)
  
  image_tensor = get_image(tf.constant(path))
  # convert to uint8
  image_tensor = tf.image.convert_image_dtype(image_tensor, dtype=tf.uint8)
  with tf.Session() as sess:
      image = sess.run(image_tensor)
  
  cv2.imshow(&quot;tf&quot;, image)
  cv2.imshow(&quot;original&quot;, original_image)
  cv2.waitKey(0)
  </code></pre>
  <p>As you can see from the image, ther's a difference between the image read by OpenCV (right colors) and by Tensorflow (wrong colors).</p>
  <p><a href="https://i.stack.imgur.com/ReHDh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ReHDh.png" alt="tensorflow vs opencv" /></a></p>
  <p>I tried to normalize the colors of the Tensorflow image using <code>cv2.normalize(image, image, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8UC3)</code> but nothing changed.</p>
  <p>I've also tryed to read the image as <code>tf.uint8</code> (removing the initiall cast to <code>tf.float32</code>) but no changes.</p>
  <p>How can I display the image read with Tensorflow, using OpenCV properly?</p>