Nodes/comfyui_cv/CV Mosaic (RGB -> Bayer CFA)
ComfyUI Node

CV Mosaic (RGB -> Bayer CFA)

Mosaics a 3-channel RGB image down to a single-channel Bayer Colour-Filter-Array (CFA): at each pixel it keeps only the ONE channel that a real Bayer sensor would sample there, following a 2x2 pattern. This is the inverse of cv2.demosaicing - use it to build a synthetic CFA from a ground-truth RGB (no licence-safe RAW Bayer sample exists), then demosaic it back and score the reconstruction (PSNR / absdiff) to see the zipper / moire artifacts each algorithm leaves. The pattern names the top-left 2x2 layout (RGGB = Red at (0,0)); feed the result into a cv2.demosaicing node whose code is COLOR_Bayer<pattern>2RGB(_VNG/_EA).

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Mosaic (RGB -> Bayer CFA)
  • nparray
  • cfa
patternRGGB
Categoryimage/CV/low-level

Inputs (2)

NameTypeDefaultDescription
nparrayNPARRAYRGB image [H,W,3] (channel 0 = R). Use 'Image -> CV Array' in RGB mode to produce it. A single-channel input is treated as already-mosaiced and passed through unchanged.
patternCOMBORGGBCFA layout of the top-left 2x2 block. RGGB = R at (0,0), G at (0,1) and (1,0), B at (1,1) - the most common sensor. Must match the demosaicing code downstream (COLOR_Bayer<pattern>2RGB...).

Outputs (1)

NameTypeDescription
cfaNPARRAYSingle-channel [H,W] CFA (same dtype as the input) - one colour sample per pixel. Feed it into cv2.demosaicing.