BayerRG -> RGB conversion

Hello,

Is there a bug in BayerRG to RGB conversion in OpenCV?

After a lot of research, I have isolated my test case to the following.

import cv2
import numpy as np
import matplotlib.pyplot as plt

# Simple matrix in BayerRG layout of a 6x12 image with all red pixels
I = np.uint8([
    255, 0, 255, 0, 255, 0, 
    0, 0, 0, 0, 0, 0,
    255, 0, 255, 0, 255, 0,
    0, 0, 0, 0, 0, 0,
    255, 0, 255, 0, 255, 0,
    0, 0, 0, 0, 0, 0,
    255, 0, 255, 0, 255, 0,
    0, 0, 0, 0, 0, 0,
    255, 0, 255, 0, 255, 0,
    0, 0, 0, 0, 0, 0,
    255, 0, 255, 0, 255, 0,
    0, 0, 0, 0, 0, 0
          ]).reshape(12, 6)

# Convert BayerRG --> RGB
# NOTE: OpenCV often uses the BGR layout, but here I'm asking for RGB layout explicitly
J = cv2.cvtColor(I, cv2.COLOR_BayerRG2RGB)

# This will show all pixels as blue, which is not what I expect.
plt.imshow(J)

To confirm that the convert image J should indeed be red, feed the same example to MATLAB with the following code, by going to Convert Bayer pattern encoded image to truecolor image - MATLAB demosaic and clicking on “Try This Example” to open interactive coding window.

I = uint8([
255, 0, 255, 0, 255, 0; ...
0, 0, 0, 0, 0, 0; ...
255, 0, 255, 0, 255, 0; ...
0, 0, 0, 0, 0, 0; ...
255, 0, 255, 0, 255, 0; ...
0, 0, 0, 0, 0, 0; ...
255, 0, 255, 0, 255, 0; ...
0, 0, 0, 0, 0, 0; ...
255, 0, 255, 0, 255, 0; ...
0, 0, 0, 0, 0, 0; ...
255, 0, 255, 0, 255, 0; ...
0, 0, 0, 0, 0, 0
]);

J = demosaic(I,'rggb');

fig=figure, imshow(J); truesize(fig, [48, 24]);

I have tried 2 different versions of cv2: 4.5.1 & 3.4.7. The issue exists in both.

Can anyone please confirm the bug? I

Thanks.