Nodes/opencv-comfyui/OpenCV reduce_1
ComfyUI Node

OpenCV reduce_1

Reduce_1 — the same column/row reduction, twice for free

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV reduce_1
  • src
  • dst
  • nparray
dim
rtype
dtype

reduce_1 is reduce_0 with a different label. Same inputs, same output, same behavior - the pack generated one node per overload it found in OpenCV's type stubs, and this overload happens to be listed twice. Pick whichever, and save yourself the moment of panic when you see the same node under two names and assume you're missing something.

What it does, briefly: collapses an NPARRAY along one axis into a single vector. dim picks the direction (0 → row vector, one value per image column; 1 → column vector, one value per row), and rtype picks the reduction - 0 sum, 1 average, 2 max, 3 min. The dtype int controls the output type (-1 keeps the source), and the optional dst is OpenCV's out-parameter leaking through the generator - leave it alone.

You'd use it for projection analysis: average each row of a grayscale image to find a scanline, or each column to find where a bright region starts and ends. The full treatment is in the reduce_0 article; if you landed here directly, the one thing to remember is that the output is a 1-D vector, not an image, so don't route it into Nparrays2Image.

It's part of opencv-comfyui (geroldmeisinger/opencv-comfyui). Install is the standard song: ComfyUI Manager (search "opencv-comfyui"), or

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

restart, and confirm OpenCV is present:

pip install opencv-contrib-python

No models to download, nothing GPU-bound - it's a numpy-level reduction, and the pack even lists "blacklist functions which don't make sense in ComfyUI" as a todo item, which is your warning that among the six hundred generated nodes there are duplicates like this one. The pattern to internalize: when this pack hands you _0 and _1 twins, they're the same overload twice. Use one, bookmark it, and move on.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
srcNPARRAY
dimINT
rtypeINT
dtypeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY