-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Channel order for demosaicing #18619
Description
System information (version)
- OpenCV => opencv_python-4.4.0.44-cp37-cp37m-manylinux2014_x86_64
- Operating System / Platform => Ubuntu 16
- Compiler => Python 3.7
Detailed description
Heyho,
If I create a bayer pattern (e.g. ndarray:(128,128)) with the pattern RGGB
RG RG ...
GB GB ...
255 0 255 0
0 0 0 0
I would expect that this will be converted to a pure red image (e.g. ndarray:(128,128, 3)) using opencv demosaicing (COLOR_BAYER_RG2BGR). Unfortunately the result is a blue image (BGR ordering), so output[:,:,0] == 255 which would be right if the output would have RGB ordering but I explicitly used COLOR_BAYER_RG2BGR!
Steps to reproduce
import numpy as np
import cv2
rggb = np.zeros((128, 128), np.uint8)
rggb[::2, ::2] = 255
bgr_debayered = cv2.demosaicing(rggb, cv2.COLOR_BAYER_RG2BGR)
cv2.imwrite("debayered_should_be_red_but_is_blue.png", bgr_debayered)
Issue submission checklist
- I report the issue, it's not a question https://answers.opencv.org/question/236504/pixel-order-for-demosaicing/
- I checked the problem with documentation, FAQ, open issues,
- I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc
Any help would be appreciated to understand the change in channel ordering here.