Image output as BGR & RGB explanation

Hi
Here instructor is telling that matplotlib reads an image as BGR but we need to display it is as RGB to view it as original. And he is telling that when viewed through cv2.imshow image is displayed as BGR i.e it reads a RGB image as BGR and shows it as BGR. So how come original image is displayed when image is of format RGB ? please explain in detail both the concepts

Hey @pasta, it appears you are completely confused, here is bried description that will surely help you out.

  1. plt.imread(img)- matplotlib plt reads image and stores in rgb format
  2. plt.imshow(img)- matplotlib plt displays image considering that input image is in rgb format.
  3. cv2.imread(img)- opencv reads image and stores in bgr format
  4. cv2.imshow(img)- opencv displays image considering that input image is in bgr format.

Now, you can see yourself when you need to change the channels and when not.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush: