OpenCV BGR2RGB Conversion

  matplotlib, opencv, python

I am trying to learn OpenCV and I am new to these things(Python, OpenCV).

Here is the link that i am following And here is the part i don’t understand

In lesson 1. There is a subject about why we should use RGB and BGR conversion. I understand that matplotlib is using RGB and OpenCV is using BGR (Correct me if i’m wrong). But couldn’t get how to convert BGR to RGB with this code:

coke_img_channels_reversed = coke_img[:, :, ::-1]

plt.imshow(coke_img_channels_reversed)

And I couldn’t tell if the transformation is done exactly in matrix or array.
How this code change order of BGR to RGB. Can anyone explain it mathematically or logically?

Source: Python Questions

LEAVE A COMMENT