Nodes/opencv-comfyui/OpenCV insertChannel_1
ComfyUI Node

OpenCV insertChannel_1

The duplicate overload, minus the surprises

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV insertChannel_1
  • src
  • dst
  • nparray
coi

Let's get the elephant in the room out of the way: OpenCV insertChannel_1 does the same thing as OpenCV insertChannel_0. Same cv2.insertChannel call, same three inputs, same output. This pack is generated straight from OpenCV's type-stub files, and insertChannel appears there twice - once annotated with MatLike, once with UMat - so the generator produced two numbered nodes. With real nparrays there is no behavioral difference, and no reason to prefer one over the other. Read the insertChannel_0 article for the mechanics; this page is the "why two?" explainer plus the specific quirks you'll hit on this one.

What it does

Copies a single-channel image into one channel slot of a multi-channel target. src is the channel, dst is the image being modified, coi is the zero-based channel index to replace (in BGR order - 0 blue, 1 green, 2 red). Classic use: process one channel by itself, then stitch it back into the original with the other planes untouched. It pairs naturally with the pack's extractChannel_0/1.

Inputs and outputs (same as insertChannel_0)

  • src - single-channel NPARRAY, the channel to copy in.
  • dst - multi-channel NPARRAY, the image being modified.
  • coi - INT, which channel slot to overwrite.
  • Output nparray - the modified dst.

One quirk worth repeating because it's the same in both variants: dst is a required input even though the function overwrites it. The generator only makes out-parameters optional when the stub types them | None, and this one doesn't. So you must connect a target image, and you must consume the output socket - the node returns the modified array and ComfyUI's DAG won't magically update your upstream dst.

Installing

Same single-pack story as every node on this list:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
cd opencv-comfyui
pip install -r requirements.txt

or search "opencv-comfyui" in ComfyUI Manager. No model downloads; requirements.txt is opencv-contrib-python, numpy, torch.

Gotchas

Everything from the _0 twin applies: src must be genuinely single-channel, src and dst must match in size, and you should stay at batch_size == 1 (the pack throws Only images with batch_size==1 are supported! otherwise). One thing that's different here is only psychological - because it's numbered _1, people assume it's the "advanced" variant and reach for it expecting more options. It isn't. There are no hidden parameters; info_schema is identical to insertChannel_0. If a workflow you downloaded uses this one instead of _0, that's just which overload the author happened to drag in - don't treat it as meaningful, and don't hesitate to swap it for the other if your graph is tidier that way.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
srcNPARRAY
dstNPARRAY
coiINT

Outputs (1)

NameTypeDescription
nparrayNPARRAY