Nodes/opencv-comfyui/OpenCV connectedComponentsWithStatsWithAlgorithm_1
ComfyUI Node

OpenCV connectedComponentsWithStatsWithAlgorithm_1

The kitchen-sink blob node, duplicated (connectedComponentsWithStatsWithAlgorithm_1)

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV connectedComponentsWithStatsWithAlgorithm_1
  • image
  • labels
  • stats
  • centroids
  • int
  • nparray_1
  • nparray_2
  • nparray_3
connectivity
ltype
ccltype

connectedComponentsWithStatsWithAlgorithm_1 is the duplicate of connectedComponentsWithStatsWithAlgorithm_0 - same cv2.connectedComponentsWithStatsWithAlgorithm call, same four outputs, identical code. The pack's generator emits a node per overload in OpenCV's type stubs, this function declared two signatures, and both shipped. Use the _0 node; this one is the numbering system being thorough.

The short version

The fullest connected-components node in the pack: label blobs, get stats, pick the algorithm.

  • image (NPARRAY) - 8-bit single-channel binary mask. Convert via Image2Nparray + cvtColor (code=6, BGR2GRAY) or get 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, 2 CCL_GRANA, 3 CCL_BOLELLI, 4 CCL_SAUF, 5 CCL_BBDT, 6 CCL_SPAGHETTI. Start at 0.
  • labels / stats / centroids (NPARRAY, optional) - out-parameters; skip them.
  • Outputs: int (component count), nparray_1 (labels), nparray_2 (stats - left/top/width/height/area per blob), nparray_3 (centroids).

Classic use: mask cleanup - count objects and filter speckles by area from the stats rows.

Install

Same as the whole pack:

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

or ComfyUI Manager → "opencv-comfyui". Needs opencv-python-contrib. Watch the pack-wide guidedFilter OpenCV conflict and Image2Nparray's batch-size-1 limit. And that's genuinely it - every sentence on this page applies to the _0 node too, so if you came here wondering whether _1 does something extra, it doesn't.

Categoryimage/OpenCV

Inputs (7)

NameTypeDefaultDescription
imageNPARRAY
connectivityINT
ltypeINT
ccltypeINT
labelsoptNPARRAY
statsoptNPARRAY
centroidsoptNPARRAY

Outputs (4)

NameTypeDescription
intINT
nparray_1NPARRAY
nparray_2NPARRAY
nparray_3NPARRAY