OpenCV erode_1
Erode_1 — the identical twin of erode_0, minus the confusion
- src
- kernel
- dst
- nparray
Straight answer: erode_1 is a duplicate of erode_0. Same inputs, same output, same generated code - if you open the pack source and diff the two classes, they're copy-paste twins. You can use either one and get identical results. If you're deciding, just click erode_0 and move on with your life.
Why does the twin exist? opencv-comfyui (geroldmeisinger/opencv-comfyui) is auto-generated: it parses OpenCV's type stubs and emits one node per function overload, numbered _0, _1, etc. OpenCV's erode is declared a couple of times in the stubs (mostly differing in how the optional dst out-parameter shows up), and when the overloads are functionally identical, the generator spits out two lookalike nodes. It's a byproduct of the pipeline, not a feature you're supposed to choose between.
What it does
Morphological erosion: erases small white specks, shrinks bright regions, and thins features in a binary image or mask. In a typical ComfyUI workflow that means cleaning up a mask - killing the 1-pixel noise and separating blobs that are just barely touching - before you send it to something downstream. It's the counterpart to dilate (which grows bright regions), and together they're the standard mask-tidy pair. Deterministic, instant, no model involved.
Inputs and outputs
- src (NPARRAY) - the image or mask to erode.
- kernel (NPARRAY) - the structuring element as a matrix, typically built with the pack's
getStructuringElement_0node. - anchor (STRING) - literal string, default
(-1, -1)for center. - iterations (INT) - how many passes; bump this before building a giant kernel.
- borderType (INT) - border enum,
0(BORDER_CONSTANT) is the safe default. - borderValue (STRING) - literal border value, e.g.
0. - dst (NPARRAY, optional) - OpenCV out-parameter, leave unconnected.
- Output: nparray - the eroded result.
Wiring it up
Same pattern as every node in this pack: Image2Nparray in, Nparrays2Image out, and remember this pack speaks BGR. The kernel is the one input you must actually build - there's no "size" widget, you feed a structuring element nparray from getStructuringElement_0.
Install and gotchas
Install via ComfyUI Manager (search "opencv-comfyui") or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, then restart. Requirements are opencv-contrib-python, numpy, torch; no models to fetch. The pack's own warning: "Expect dragons!" - the string fields parse as Python literals, so invalid syntax (<unknown>, line 0) means you typed anchor or borderValue wrong. That and the -215 grayscale assertion (fix with cvtColor code 6) are the two errors you'll actually meet. Full walkthrough and troubleshooting live on the erode_0 page - this one is just the twin.
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 | — |