Python | cv2.imshow() loading arrays as BGR?
07:28 30 Jan 2019

I have recorded some data as npy file. And I tried to diplay the image (data[0]) to check if it makes sense with the following code

import numpy as np
import cv2

train_data = np.load('c:/data/train_data.npy')

for data in train_data:
    output = data[1]
    # only take the height, width and channels of the 4 dimensional array
    image = data[0][0, :, :, :]
    # image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    cv2.imshow('test', image)
    print('output {}'.format(output))
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break

But if I display the images without the line image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) the images seem to be BGR based. If I comment this line into the code the images are displayed correctly.

My question: Does this observation imply that the image array is already in BGR format? Or does this imply that cv2.imshow() does by default interprete the array as BGR array?

python opencv numpy-ndarray