dom free
dom free

Reputation: 1235

It looks like opencv swaps the blue and red channels?

enter image description here

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

Answers (2)

Jeru Luke
Jeru Luke

Reputation: 21203

Rather simple option would be swapping the R and B channels:

img = img[:, :, ::-1]

Upvotes: 4

ZdaR
ZdaR

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

Related Questions