Nodes/opencv-comfyui/OpenCV cvtColor_1
ComfyUI Node

OpenCV cvtColor_1

The Twin That's Identical to cvtColor_0 (Just Pick One)

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

OpenCV cvtColor_1 is cvtColor_0's identical twin, and the whole useful story about it is: don't spend time choosing between them. Both call the same cv2.cvtColor, both take the same inputs, both return a converted nparray. The _1 suffix is a side effect of how this pack is generated, not a different algorithm.

Here's why the numbering exists. geroldmeisinger/opencv-comfyui auto-generates one ComfyUI node per overload it finds in cv2's Python type stubs. OpenCV declares most functions twice - once for MatLike (the normal numpy-backed image) and once for UMat (OpenCV's unified memory wrapper). The generator dutifully emits both as separate nodes, and since ComfyUI can't distinguish the input types, you get two functionally identical wrappers. cvtColor_0 and cvtColor_1 are that pair. The same pattern repeats all over this pack: dct_0/dct_1, decolor_0/decolor_1, and so on.

What it does

Converts an image between color spaces using an integer enum code:

  • 6 = BGR2GRAY
  • 8 = GRAY2BGR
  • 4 = BGR2RGB

This matters in this pack specifically because ComfyUI images are RGB float32 tensors in 0–1, while OpenCV works on BGR uint8 nparrays in 0–255. The conversion nodes Image2Nparray/Nparrays2Image handle the RGB/BGR flip at the boundaries, but anything needing grayscale or a different channel order passes through here first. See the cvtColor_0 article for the full walkthrough - it's the same node.

Inputs and outputs

Same as the twin:

  • src (NPARRAY) - input image from Image2Nparray.
  • code (INT) - conversion enum (6 for grayscale, etc.).
  • dstCn (INT) - output channels; 0 lets OpenCV infer it.
  • hint (INT) - conversion hint, default 0.
  • dst (NPARRAY, optional) - the out-parameter; leave it unconnected, the README says so.
  • nparray (NPARRAY, output) - the converted result.

Install

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 model downloads. Mind the package name - opencv-contrib-python, not the README's opencv-python-contrib.

If you hit img.type() == CV_8UC1 assertion errors, the function wants grayscale and you're feeding it color - run cvtColor with code 6 first. If you get 'NoneType' object has no attribute 'shape' from Nparrays2Image, you fed it something that isn't an image. And batch-size-one only, as with the whole pack. Everything else, you can find in the cvtColor_0 article.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
srcNPARRAY
codeINT
dstCnINT
hintINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY