We already mentioned that OpenCV uses the BGR color format instead of the RGB one. This can be seen in the following diagram, where you can see the order of the three channels:
The pixel structure of a BGR image can be seen in the following diagram. In particular, we have detailed how to access pixel (y=n, x=1) for clarification purposes:
Initial developers at OpenCV chose the BGR color format (instead of the RGB one) because at the time, the BGR color format was very popular among software providers and camera manufacturers. For example, in Windows, when specifying a color value using COLORREF, they used the BGR format, 0x00bbggrr (https://docs.microsoft.com/es-es/windows/desktop/gdi/colorref). In summary, BGR was chosen for historical reasons.
Additionally, other Python packages use the RGB color format. Therefore, we need to know how to convert an image...