title: Convert Numpy array to image by using OpenCV or PIL
body: <p>I am trying to convert my array to image using OpenCV or PIL libraries, In both of libraries, I am getting the images with mixed up color.</p>
  <p>This is the way I tried convert Numpy array to image using OpenCV :</p>
  <pre><code>   for i in range(len(batch_tx)):
          cls_pred = sess.run(y_pred_cls, feed_dict={x: batch_tx})
          cls_true = sess.run(tf.argmax(batch_ty, 1))
          img = cv2.resize(batch_tx[i], (FLAGS.img_size, FLAGS.img_size))
          img = cv2.cvtColor(img.astype(np.uint8), cv2.COLOR_BGR2RGB)
          cv2.imwrite(
              './saveImage/img' + str(i) + ': ' + 'True: ' + str(cls_true[i]) + ', Pred:' +
              str(cls_pred[i]) + '.JPEG', img)
  </code></pre>
  <p>The output is like below image for all my images (This is an image of a ship)</p>
  <p><a href="https://i.stack.imgur.com/i7Nza.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i7Nza.png" alt="enter image description here" /></a></p>
  <p>And I have tried PIL library as well and got the same output.</p>
  <p><code>batch_tx[1]</code> is an array of the first image in my dataset and the type is numpy.ndarray with the shape of (96,96,3)</p>
  <p>Any Idea?</p>
  <p>Thanks in advance.</p>