Nodes/ComfyUI-ArchiGraph/Canny πŸ¦β€πŸ”₯
ComfyUI Node

Canny πŸ¦β€πŸ”₯

Canny edges on CPU, thresholds in 0-to-1, no model download

By vincentfsΒ·Created 2 years agoΒ·Updated 9 months agoΒ· 3
Canny πŸ¦β€πŸ”₯
  • nparrays
  • Np_grays
β—„threshold10.40β–Ί
β—„threshold20.80β–Ί
β—„apertureSize3β–Ί
β—„L2gradienttrueβ–Ί

If you've touched ControlNet, you've touched Canny - it's the classic edge detector and the default conditioning for anything architectural, mechanical, or otherwise full of hard lines. This node is OpenCV's Canny, wrapped for ComfyUI, and it runs on CPU. As the node's own description notes, that's the difference from the Kornia-based Canny some other packs ship: no GPU, no torch kernels, just OpenCV doing its thing.

Why you'd reach for it

Two honest use cases. First, the obvious one: you want a clean edge map to feed a Canny ControlNet and you don't want to install an entire preprocessor collection to get it. This packs the whole thing into one node. Second, and often more useful: Canny edges are a great intermediate for this pack's other OpenCV nodes - the edges output is binary, which is exactly what Hough line detection and contour finding want to chew on.

How it works

Standard Canny: the node converts your image to grayscale if needed, applies Sobel gradients, then hysteresis thresholding to keep only strong edges connected to medium ones. It processes batches, and returns Np_grays as an NPARRAY shaped [B, H, W] - that's a single-channel grayscale batch, not the RGB you fed in.

The inputs that matter:

  • threshold1 / threshold2 (defaults 0.4 / 0.8): the two hysteresis thresholds. Here's the trap - they're normalized 0.0–0.99 and the node multiplies by 255 internally. So the defaults are really 102 / 204 in classic OpenCV terms. If you came from OpenCV and typed 100 and 200 expecting raw values, you've just asked for ~0.4 and 0.8% thresholds and you'll get noise soup.
  • apertureSize (3/5/7): Sobel aperture, must be odd.
  • L2gradient (default on): uses the more accurate L2 gradient norm instead of the cheaper L1 approximation.

Feed it an NPARRAY, which in this pack means running your IMAGE through the To Nparray node first (it flips RGB→BGR like OpenCV expects). Wire the output through To Image to preview it.

The workflow

Load Image β†’ To Nparray β†’ Canny β†’ To Image β†’ (preview, save, or feed a ControlNet). The node description's advice is real: for noisy inputs, run a blur before Canny - GaussianBlur then Canny is the classic recipe, and this pack has both.

Install

ComfyUI Manager β†’ search ComfyUI-ArchiGraph, or:

cd ComfyUI/custom_nodes
git clone https://github.com/vincentfs/ComfyUI-ArchiGraph

Restart, then run the pack's install script once - the requirements are OpenCV-heavy, so the first launch may take a moment. No model files at all.

Gotchas

  • Thresholds are 0-to-1, not 0-to-255. This is the #1 way people burn themselves on this node.
  • CPU-only. Fine for a single edge map; annoying if you're batch-processing hundreds of frames.
  • Output is a single-channel NPARRAY, so you need the To Image node (or this pack's nparray save utilities) before most ComfyUI image nodes will accept it.

For a self-contained Canny that plugs into ControlNet or feeds Hough/contour pipelines, this is the one in this pack you'll actually use.

CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ“€ OpenCV

Inputs (5)

NameTypeDefaultDescription
nparraysNPARRAYβ€”
threshold1FLOAT0.400.01–0.99First threshold for the hysteresis procedure.
threshold2FLOAT0.800.01–0.99Second threshold for the hysteresis procedure.
apertureSizeINT33–7Aperture size for the Sobel operator.
L2gradientBOOLEANtrueA flag, indicating whether a more accurate L2 norm should be used to calculate the image gradient magnitude.

Outputs (1)

NameTypeDescription
Np_graysNPARRAYβ€”