(from https://www.scivision.co/numpy-image-bgr-to-rgb/)
Conversion between any/all of BGR, RGB, and GBR may be necessary when working with Matplotlib expects M x N x 3 image, where last dimension is RGB.
OpenCV expects M x N x 3 image, where last dimension is BGR.
Scientific Cameras, some of which output an M X N x 3 image, where last dimension is GBR
OpenCV image to Matplotlib
rgb = bgr[...,::-1]
Matplotlib image to OpenCV
bgr = rgb[...,::-1]
gbr = rgb[...,[2,0,1]]
3-D: W x H x 3, where the last axis is color (e.g. RGB) 4-D: W x H x 3 x 1 is typically an alpha channel