Reputation: 1235
I am new to opencv. I found the following code swaps red and blue channel when I fed sRGB png to it. Which function should I blame, imread or fromarray?
Upvotes: 4
Views: 5592
Reputation: 21203
Rather simple option would be swapping the R and B channels:
img = img[:, :, ::-1]
Upvotes: 4
Reputation: 22954
Yes, OpenCV follows BGR color convention internally. However, you may either use cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
before displaying your image using a third party function(display()
in this case). Or you can also use cv2.imshow()
method to debug images, which doesn't require cv2.cvtColor()
Upvotes: 7