CV FloodFill Flags
Stop hand-OR-ing bit values into cv2.floodFill
- flags
- value
Most of this pack's ~470 raw cv2.* wrappers take plain numbers, and you can type those into a widget. cv2.floodFill doesn't. Its flags argument is a packed integer - connectivity in the low byte, the value the mask gets filled with in bits 8–15, and the FLOODFILL_* mode bits stacked on top - and nobody is reading that out of the docs and typing it correctly. This node authors it once and fans it out.
It's a flag-builder from bmad4ever's ComfyUI CV (bmad4ever/comfyui_cv, forked from Gerold Meisinger's opencv-comfyui). There's a family of them - Warp, DFT, DCT, Optical Flow, Chessboard, GEMM, SVD, Threshold - all one shape: a single flags string in, a string and an integer out.
What the toggles do
flags is a pipe-joined list of cv2 constant names, which the frontend renders as a base dropdown plus one checkbox per flag. The base picks connectivity and the mask fill value together, because in cv2 they share the field:
4-connectivity (mask filled with 1)- the default, and cv2's own8-connectivity (mask filled with 1)4-connectivity, mask filled with 2558-connectivity, mask filled with 255
Then two independent bits:
- FLOODFILL_FIXED_RANGE - compare each candidate pixel against the seed pixel rather than against its neighbours. That turns flood fill from a region-grower into a global tolerance threshold, which is the difference between filling a solid patch and filling everything vaguely similar to where you clicked.
- FLOODFILL_MASK_ONLY - fill the mask, leave the image untouched. This is the one you actually want most of the time when you're building masks rather than editing pixels.
The 1-vs-255 choice matters for the same reason: a mask filled with 1 is a valid flag map and a useless visual, and it will quietly under-saturate anything downstream that expects 0–255.
Outputs
- flags - the same pipe-joined string, resolved. Wire it into the
flagsinput of any number ofcv2_floodFillnodes. - value - the resolved integer, the OR of the constants. That's for the raw
intflag params on other nodes, or for a MathExpression.
The string isn't just cosmetic: the node validates the names when it resolves them, so a typo is a loud error instead of a silently different bit pattern.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
pip install "opencv-contrib-python-headless~=5.0.0.93"
Or search ComfyUI CV in ComfyUI Manager. Python ≥ 3.12 and a V3-API ComfyUI.
When you'd bother
This is plumbing, in the exact sense the node-plumbing layer is plumbing: one source, many consumers. If three flood fills in one graph need to share a configuration, this is where you change it once. And if you're writing flags for a cv2_floodFill you found in the registry and have no idea what integer to feed it - this node is the answer. No shipped workflow uses it; it's here because the raw wrapper is unusable without it. If you're not touching cv2_floodFill at all, you can safely ignore it forever.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| flags | STRING | 4-connectivity (mask filled with 1) | Pipe-joined cv2 constant names, e.g. "4-connectivity (mask filled with 1) | FLOODFILL_FIXED_RANGE". In the UI this renders as a base dropdown with one toggle per flag. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| flags | STRING | The pipe-joined flags string - wire it into the flags input of cv2_floodFill nodes. |
| value | INT | The resolved integer (constants OR-ed together). |