Nodes/opencv-comfyui/OpenCV floodFill_1
ComfyUI Node

OpenCV floodFill_1

The same paint bucket, second stub

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV floodFill_1
  • image
  • mask
  • int
  • nparray_1
  • nparray_2
  • literal
seedPoint
newVal
loDiff
upDiff
flags

By now you know the drill with this pack: _0 and _1 suffixes mean "two auto-generated overload stubs," and for some functions they're byte-for-byte identical. floodFill_1 is one of those. It does exactly what floodFill_0 does - flood-fill a connected region of an image from a seed point, paint-bucket style - and you can use either node and get the same result.

So rather than re-argue the mechanism, let's make sure you can actually drive it, because this is one of the pack's most useful nodes and also one of its least friendly. The pain points are the string parameters.

The inputs, decoded

  • image (NPARRAY) - the image to fill, routed through Image2Nparray.
  • seedPoint (STRING) - where to start, as a Python tuple literal: (100, 200).
  • newVal (STRING) - the fill color as a BGR tuple: (255, 0, 0). Yes, BGR, because this is OpenCV land.
  • loDiff / upDiff (STRING) - color tolerance below/above the seed, e.g. (10, 10, 10).
  • flags (INT) - 4 or 8 for connectivity; add 65536 for fixed-range mode. Start with 4.
  • mask (NPARRAY, optional) - restricts where filling happens; skip it initially.

Every STRING input is parsed with ast.literal_eval, so the syntax has to be a valid Python literal - parentheses, commas, no quotes around the tuple itself. A stray typo gives you the pack's invalid syntax error.

Outputs

int = number of pixels filled. nparray_1 = the filled image (the one you actually want - send it to Nparrays2Image). nparray_2 = the updated fill mask. literal = the filled region's bounding rectangle as a string, because Rect is a composite type the pack doesn't bother parsing.

Installing

Ships in geroldmeisinger/opencv-comfyui. ComfyUI Manager: search "opencv-comfyui". Or:

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

Restart ComfyUI. The pack's requirements.txt installs opencv-contrib-python, numpy, and torch.

Common issues

Pack-wide rules: Image2Nparray is single-batch only, keep the IMAGE → Image2Nparray → … → Nparrays2Image chain, and mind BGR-vs-RGB. Flood-fill-specific: a fill that bleeds everywhere means tolerance too high (or a smooth gradient in the image); a fill that does nothing means the seed point is out of bounds or your literals are malformed.

And the standing caveat about duplicates: this pack is generated, not hand-tuned, and the README says so flatly - "Expect dragons!" When two nodes are identical, it's not a conspiracy, it's the generator's output. Pick floodFill_0 or floodFill_1, whichever your muscle memory prefers, and get on with filling regions.

Categoryimage/OpenCV

Inputs (7)

NameTypeDefaultDescription
imageNPARRAY
seedPointSTRING
newValSTRING
loDiffSTRING
upDiffSTRING
flagsINT
maskoptNPARRAY

Outputs (4)

NameTypeDescription
intINT
nparray_1NPARRAY
nparray_2NPARRAY
literalSTRING