ComfyUI Node
CV Keep Largest Component
Keeps only the single largest connected component of a binary mask (cv2.connectedComponentsWithStats), dropping every smaller blob - the standard way to isolate one object from scattered noise or secondary movers before seeding GrabCut / watershed. Unlike 'Select Component At Point' it needs no probe location: it just takes the biggest blob by area. Failure-tolerant: an empty mask (no foreground) yields found=false and an empty mask, not an error.
CV Keep Largest Component
- image
- mask
- area
- found
◄connectivity8►
Categoryimage/CV/contours
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMFY_MATCHTYPE_V3 | Binary image (or MASK); non-zero = foreground. The mask comes back in this input's format. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| connectivity | COMBO | 8 | 8 also connects diagonal pixels; 4 only direct neighbours. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask | COMFY_MATCHTYPE_V3 | 0/255 mask of the largest component, in the image input's format. |
| area | INT | Pixel area of the kept component (0 if none). |
| found | BOOLEAN | — |