Nodes/opencv-comfyui/OpenCV connectedComponentsWithAlgorithm_1
ComfyUI Node

OpenCV connectedComponentsWithAlgorithm_1

The algorithm-picking blob counter, duplicated (connectedComponentsWithAlgorithm_1)

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV connectedComponentsWithAlgorithm_1
  • image
  • labels
  • int
  • nparray
connectivity
ltype
ccltype

connectedComponentsWithAlgorithm_1 is the duplicate of connectedComponentsWithAlgorithm_0 - same cv2.connectedComponentsWithAlgorithm call, same inputs, same two outputs. The pack generates a node per overload in OpenCV's type stubs, this one declared two signatures, and the generator shipped both. Use the _0 node; this twin is just the numbering system doing its thing.

The short version

Counts the connected components (blobs) in a binary mask, with an explicit algorithm choice:

  • image (NPARRAY) - 8-bit single-channel binary mask. Convert via Image2Nparray + cvtColor (code=6, BGR2GRAY) or face the CV_8UC1 assertion.
  • connectivity (INT) - 4 or 8. Use 8.
  • ltype (INT) - 4 (CV_32S) or 2 (CV_16U). Use 4.
  • ccltype (INT) - 0 CCL_DEFAULT, 1 CCL_WU (fast union-find), 2 CCL_GRANA, 3 CCL_BOLELLI, 4 CCL_SAUF (good with very many labels), 5 CCL_BBDT, 6 CCL_SPAGHETTI.
  • labels (NPARRAY, optional) - out-parameter; skip.
  • Outputs: int (component count, background included) and nparray (label map).

In practice ccltype=0 or 1 is all you'll need; the rest is tuning for pathological cases.

Install

Standard pack install:

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

or ComfyUI Manager → "opencv-comfyui". Needs opencv-python-contrib. Pack-wide traps: conflicting OpenCV installs (Cannot import name 'guidedFilter' from 'cv2.ximgproc') and Image2Nparray's batch-size-1 limit. That's the whole story - nothing on this page differs from the _0 page except the name, and nothing about your workflow changes if you use either.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
imageNPARRAY
connectivityINT
ltypeINT
ccltypeINT
labelsoptNPARRAY

Outputs (2)

NameTypeDescription
intINT
nparrayNPARRAY