title: How to swap blue and red channel in an image using OpenCV
body: <p>I am facing a little bit of problem in swapping the channels (specifically red and blue) of an image. I am using Opencv 3.0.0 and Python 2.7.12. Following is my code for swapping the channels</p>
  <pre class="lang-py prettyprint-override"><code>import cv2
  
  img = cv2.imread(&quot;input/car1.jpg&quot;)
  
  #The obvious approach
  Cimg = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
  
  #Manual Approach
  red = img[:,:,2]
  blue = img[:,:,0]
  
  img[:,:,0] = red
  img[:,:,2] = blue
  
  cv2.imshow(&quot;frame&quot;,Cimg)
  cv2.imshow(&quot;frame2&quot;, img)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>
  <p>I am unable to figure out why the same image undergoing through the same(probably) operation is giving two different outputs. Can someone throw some light on what's going wrong?</p>
  <p>Original Image
  <a href="https://i.stack.imgur.com/q4Myt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q4Myt.jpg" alt="The original Image" /></a></p>
  <p>Manual Operation
  <a href="https://i.stack.imgur.com/dtjaK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dtjaK.png" alt="The manual operation" /></a></p>
  <p>COLOR_BGR2RGB
  <a href="https://i.stack.imgur.com/1jMsb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1jMsb.png" alt="The cv2.COLOR_BGR2RGB operation" /></a></p>