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?
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()
Rather simple option would be swapping the R and B channels:
img = img[:, :, ::-1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With