OpenCV dilate_1
Dilate_1 is dilate_0 with a different suffix — grow your masks anyway
- src
- kernel
- dst
- nparray
dilate_1 is the twin of dilate_0: same cv2.dilate call, same six required inputs, same single NPARRAY output. The _1 suffix is the opencv-comfyui generator's overload numbering - OpenCV declares the function for MatLike and for UMat, the pack makes a node per declaration, and both end up identical on the Comfy side. You don't need to choose carefully; there's no hidden difference. The real content is on the dilate_0 page, and here's the summary.
Dilation is the mask-growth workhorse. Each foreground pixel becomes the maximum of its neighborhood, defined by a structuring-element kernel, so bright regions in a binary mask expand by roughly the kernel's radius. That's how you turn a too-tight inpainting or detailing mask into a safe one with clean blending edges - a hairline mask leaks seams, a dilated mask doesn't. Multiple passes (iterations) give you controlled growth. It's deterministic, costs milliseconds, and it's the exact kind of operation the KB's post-processing layer exists to point you at instead of re-rolling the generation.
Inputs: src (NPARRAY, your mask), kernel (NPARRAY - note the pack ships no getStructuringElement, so an all-ones 3×3 or 5×5 numpy array from another pack's numpy node is the practical kernel), anchor (STRING as a Python literal - (-1, -1) for center), iterations (INT, 1–3 typical), borderType (INT, 0 = BORDER_CONSTANT), borderValue (STRING literal). The anchor and borderValue strings are the pack's trap: they're parsed with ast.literal_eval, so bad syntax like -1, -1 instead of (-1, -1) throws the README's invalid syntax error. Skip the optional dst out-parameter. Output: one nparray.
And the pack-wide plumbing, which applies verbatim here: images travel as NPARRAY, not Comfy IMAGE. Put Image2Nparray in front and Nparrays2Image behind, and keep batch_size==1 (ImageFromBatch with length=1 if a batch shows up).
Install: part of geroldmeisinger/opencv-comfyui - ComfyUI Manager → search "OpenCV", or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
restart, with opencv-contrib-python installed. The pack's most common install failure is Cannot import name 'guidedFilter' from 'cv2.ximgproc' from conflicting OpenCV wheels - fix the wheel conflict and the whole pack loads.
Reality check: if you need to grow a mask, you want this node (or its _0 twin) in your graph. If you're only deciding between the two suffixes, flip a coin. Identical.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| kernel | NPARRAY | — | |
| anchor | STRING | — | |
| iterations | INT | — | |
| borderType | INT | — | |
| borderValue | STRING | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |