OpenCV connectedComponentsWithAlgorithm_1
The algorithm-picking blob counter, duplicated (connectedComponentsWithAlgorithm_1)
- image
- labels
- int
- nparray
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 theCV_8UC1assertion. - connectivity (INT) -
4or8. Use8. - ltype (INT) -
4(CV_32S) or2(CV_16U). Use4. - ccltype (INT) -
0CCL_DEFAULT,1CCL_WU (fast union-find),2CCL_GRANA,3CCL_BOLELLI,4CCL_SAUF (good with very many labels),5CCL_BBDT,6CCL_SPAGHETTI. - labels (NPARRAY, optional) - out-parameter; skip.
- Outputs:
int(component count, background included) andnparray(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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY | — | |
| connectivity | INT | — | |
| ltype | INT | — | |
| ccltype | INT | — | |
| labelsopt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| int | INT | — |
| nparray | NPARRAY | — |