OpenCV Canny_3
Canny_3 — the gradient-based Canny, and its identical twin, explained
- dx
- dy
- edges
- nparray
Canny_3 is the duplicate twin of Canny_2, and both are the other Canny - the overload that eats gradients (dx/dy) instead of a plain image. The opencv-comfyui pack generates one node per overload it finds in OpenCV's type definitions, and the gradient overload is declared for both MatLike and UMat, so you get two functionally identical nodes. There's no hidden feature in the _3; use whichever the graph lets you grab.
So, gradient-based Canny: why does it exist? Edge detection is two stages - derivative computation, then non-maximum suppression plus hysteresis to produce clean thin lines. The image overload (Canny_0) does both stages internally with a default Sobel. The dx/dy overload hands you the steering wheel on stage one: you supply horizontal and vertical gradient images (from Sobel, Scharr, or any custom derivative computation), and Canny does the thinning and double-thresholding on your gradients. You'd reach for it when the default Sobel isn't tuned right for your content, or when your gradients came from a non-standard source.
Inputs and outputs. dx and dy (NPARRAY) - same-shape gradient maps; threshold1 / threshold2 (FLOAT) - the hysteresis bounds (above threshold2 is a definite edge, below threshold1 is dropped, the middle survives only if connected to a strong edge); L2gradient (BOOLEAN) - use the more accurate L2 magnitude. The optional edges is an OpenCV out-parameter the generator exposed; ignore it. Output: one nparray edge map.
The realistic take. For feeding a Canny ControlNet - the classic preprocessor for architectural and mechanical subjects - you want the plain image overload. The gradient version is a specialist tool for people who care about exactly how the derivatives were computed. It's nice that it's here, and it's the same pack philosophy as everything else: 635 auto-generated cv2 functions, most of which you'll never open.
Install and quirks. Standard for this pack: ComfyUI Manager → search "OpenCV", or
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib
restart, done - no model downloads. Remember the representation rules: NPARRAY in/out (BGR 0..255 uint8), bridge from IMAGE with Image2Nparray, batch size 1 only. And the author's own motto for this pack applies: auto-generated, ugly, complex - "expect dragons."
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| dx | NPARRAY | — | |
| dy | NPARRAY | — | |
| threshold1 | FLOAT | — | |
| threshold2 | FLOAT | — | |
| L2gradient | BOOLEAN | — | |
| edgesopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |