OpenCV Canny_2
The overload for when you've already done the Sobel
- dx
- dy
- edges
- nparray
Most people know Canny as "that edge-detection thing you feed an image to." But OpenCV actually ships a second overload that takes gradients - the dx and dy derivative images - instead of a raw picture. That's this node, Canny_2, and its sibling Canny_3 is an identical duplicate of it (the pack generates one node per type-definition overload; MatLike and UMat variants come out as near-identical twins).
Why would you ever use the gradient version? Because edge detection is really two stages - compute directional derivatives, then threshold-and-thin them - and sometimes you want to control the first stage yourself. If you've already run a custom Sobel or Scharr with your own kernel size, or you're working with gradient data that came from somewhere other than the default smoothing, the dx/dy overload lets you run Canny's non-maximum suppression and hysteresis on your gradients instead of the ones OpenCV would have computed internally.
Inputs. dx and dy (NPARRAY) - the horizontal and vertical gradient images, same shape, typically from Sobel or Scharr. threshold1 / threshold2 (FLOAT) are the same hysteresis bounds as the classic Canny: pixels above threshold2 are edges, below threshold1 are dropped, the band between survives only if connected to a strong edge. L2gradient (BOOLEAN) picks the more accurate L2 gradient magnitude. The optional edges input is an exposed out-parameter - ignore it. Output is a single nparray edge map.
When you should and shouldn't reach for it. If you're preparing a Canny ControlNet condition for an architecture shot, use the image overload (Canny_0) - it's the standard path and needs no extra nodes. The dx/dy overload is for when the default Sobel stage isn't good enough: custom apertures, anisotropic gradients, or gradient data computed off-device. For most people this will sit unused in the node list, which is fine - it's here because the pack auto-generates all top-level cv2 functions, not because you need all of them.
Setup and quirks. Same pack, same rules: opencv-comfyui works in BGR 0..255 uint8 nparrays, batch_size == 1 only, so bridge with Image2Nparray and pull single frames with ImageFromBatch. No model files. Install via ComfyUI Manager (search "OpenCV") or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib
Restart after. And take the author's word for it: auto-generated, ugly, "expect dragons." The gradient-overload Canny is a genuinely useful dragon, just one most people never need to wake up.
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 | — |