How to convert BGGR 2 RGGB with opencv

Hi all, I’m OpenCV & image processing newbie.

I know that OpenCV has COLOR_BayerRGGB2BGR/COLOR_BayerRG2BGR, but does it has bayer 2 bayer like BGGR 2 RGGB?

Or what’s the opencv-way to do this if it doesn’t provide builtin support.

gentle ping for this question.

you’ll have to take the step through a full-res RGB/BGR image.

BGGR <> RGGB isn’t just swapping values in a 4-tuple of colors. it actually has to recalculate colors for pixels that don’t have that color already.

+-----+-----+    +-----+-----+
| R__ | _G_ |    | __B | _G_ |
+-----+-----+ => +-----+-----+
| _G_ | __B |    | _G_ | R__ |
+-----+-----+    +-----+-----+

that maintains the green values of those respective pixels, but the Blue in the top left one has to be interpolated from the grid, same as the Red in the bottom right. can’t just swap them. if you swapped them, you’d destroy picture content worse than mislabeled interlaced video.

1 Like

Just wondering, why do you need to have conversion between BGGR <–> RGGB?


A reference if you want to know mode about demosaicing:

1 Like