Nodes/opencv-comfyui/OpenCV extractChannel_1
ComfyUI Node

OpenCV extractChannel_1

ExtractChannel_1 — the twin, same channel-picking, no difference

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

extractChannel_1 is a byte-identical duplicate of extractChannel_0. Same inputs, same output, same generated code - the overload-twin artifact of opencv-comfyui (geroldmeisinger/opencv-comfyui), which emits one node per OpenCV stub overload and numbers them. Use _0. Nothing changes if you pick this one.

What it does

Extracts a single color channel from a multi-channel image as a grayscale output. coi is the zero-based channel index. And here's the part that matters: this pack thinks in BGR. Image2Nparray flips ComfyUI's RGB tensor to BGR before anything else runs, so coi=0 is blue, 1 is green, 2 is red (3 = alpha on a 4-channel image). If you expect RGB ordering, you'll silently grab the wrong channel - the classic footgun. Uses: pull a channel for threshold-based masking, isolate the red channel for skin-tone tricks, extract the alpha plane, or grab the V channel of an HSV image for brightness-only work.

Inputs and outputs

  • src (NPARRAY) - the multi-channel image.
  • coi (INT) - zero-based channel index (0–2 for BGR; 3 for alpha). Out of range = OpenCV error.
  • dst (NPARRAY, optional) - out-parameter; leave unconnected.
  • Output: nparray - the single extracted channel as grayscale.

Wiring it up

Image2Nparray in, this node, then back out through cvtColor code 8 (GRAY2BGR) and Nparrays2Image - though Nparrays2Image auto-converts single-channel grayscale to RGB on its own, so it may save you a step. Same flow as _0, obviously.

Install and gotchas

Via ComfyUI Manager (search "opencv-comfyui") or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, then restart. Requirements: opencv-contrib-python, numpy, torch; no model files. Pack traps apply: Image2Nparray accepts batch_size-1 only, and the author's "Expect dragons!" warning covers the raw auto-generated UI. Full walkthrough on the extractChannel_0 page.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
srcNPARRAY
coiINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY