Nodes/opencv-comfyui/OpenCV demosaicing_1
ComfyUI Node

OpenCV demosaicing_1

The Twin of the Raw-Sensor Demosaicing Node

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV demosaicing_1
  • src
  • dst
  • nparray
code
dstCn

OpenCV demosaicing_1 is the overload twin of demosaicing_0: identical cv2.demosaicing(src, code, dst, dstCn) wrapper, identical inputs, identical output. As everywhere else in geroldmeisinger/opencv-comfyui, the _1 comes from the generator emitting a node per overload in cv2's type stubs (MatLike vs UMat). Pick whichever - they behave the same.

What it's for

Converting raw single-channel Bayer-pattern data (what a camera sensor physically captures) into a full color image by interpolating the missing color channels per pixel. Niche, but real for photogrammetry or raw-camera pipelines. Diffusion users can skip it entirely.

Inputs and outputs

  • src (NPARRAY) - the raw single-channel Bayer image (8-bit).
  • code (INT) - which Bayer pattern your sensor uses and the target output, e.g. cv2.COLOR_BayerBG2BGR. Look up exact values in the OpenCV docs.
  • dstCn (INT) - output channel count; 0 to infer.
  • dst (NPARRAY, optional) - out-parameter; leave unconnected.
  • nparray (NPARRAY, output) - the reconstructed color image.

Install and gotchas

ComfyUI Manager (search opencv-comfyui) or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Restart ComfyUI. No models. The real package name is opencv-contrib-python, not the README's opencv-python-contrib; conflicting OpenCV installs surface as the guidedFilter import error (fix documented in the LayerStyle issue the README links).

Two failure modes worth knowing, same as its twin: a img.type() == CV_8UC1 assertion means your input isn't an unsigned 8-bit single-channel image, and a wrong code yields swapped colors or checkerboard shimmer - check your sensor's actual Bayer pattern rather than guessing. Full walkthrough in the demosaicing_0 article.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
srcNPARRAY
codeINT
dstCnINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY