ComfyUI Node Runs on cloud

Canny Edge

The workhorse edge detector for ControlNet

By Fannovel16·Created 3 years ago·Updated 4 months ago· 4,134
Canny Edge
  • image
  • IMAGE
low_threshold100
high_threshold200
resolution512

Canny is the classic - the edge detector most people meet first and keep using forever. It turns an image into a clean map of hard edges (thin white lines on black), and you feed that map to a Canny ControlNet to lock a generation's structure to those exact contours. It's the single most reliable "keep this composition, change everything else" preprocessor, and it's on essentially every architecture - every ControlNet union from SDXL to Flux to Z-Image has a canny mode. If you're learning one edge preprocessor, learn this one.

How it works

The Canny algorithm (it long predates AI - it's a 1986 computer-vision classic) finds edges by detecting sharp intensity gradients, then thins them to clean single-pixel lines and links them with a two-threshold hysteresis step. The output is crisp and unambiguous, which is exactly what a ControlNet wants: it's best for architecture, mechanical objects, product shots, and any scene with clear contours. It captures edges, not depth or pose - so it's strongest where the outline of a thing is the structure you care about.

The inputs that matter

The two thresholds are the whole game, and understanding them is the difference between a great Canny map and a useless one:

  • low_threshold (default 100) and high_threshold (default 200) - the hysteresis gates. A pixel's gradient above the high threshold is definitely an edge; below the low threshold, definitely not; in between, it's an edge only if it connects to a strong one. So: lower both to catch more edges (busier map - more detail, but also more noise and texture); raise both to keep only the bold structural lines (cleaner, but you might lose edges you wanted). Tuning these to your image is the skill.
  • resolution (default 512) - working size; match your generation resolution for aligned edges. The PixelPerfectResolution node in this pack computes the ideal number.

The single output is an IMAGE - the edge map - feeding a ControlNet Apply node with a Canny ControlNet (control_v11p_sd15_canny, control_canny, t2iadapter_canny, or the canny mode of your base's union model). The node makes the hint; the ControlNet model is separate.

Installing it

ComfyUI Manager: search ComfyUI's ControlNet Auxiliary Preprocessors, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Fannovel16/comfyui_controlnet_aux
pip install -r requirements.txt

Restart ComfyUI. Canny is a pure algorithm - no weights to download - so it runs instantly with no first-run pause.

Where people get burned

First and most important: preview the edge map before generating. Canny lives or dies on its thresholds, and the defaults won't suit every image. A solid wall of white lines means lower the ControlNet's job to impossible - raise the thresholds. A near-empty map missing the shape you care about - lower them. Ten seconds of previewing saves a wasted generation. Second, Canny is faithful to all edges, including texture, wrinkles, and background clutter - on a portrait or an organic subject that's often too much, and a softer preprocessor (HED/softedge, or Realistic Lineart) gives the model more breathing room. Third, the usual: no Canny ControlNet loaded means the edge map does nothing. And a weight note - modern union models publish lower canny weights than the old 1.0 default (Flux unions recommend around 0.7); starting too high overcooks the adherence and gives you a stiff, traced-looking result. Set the weight to taste and end the ControlNet partway through the steps for cleaner detail.

CategoryControlNet Preprocessors/Line Extractors

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
low_thresholdoptINT1000–255
high_thresholdoptINT2000–255
resolutionoptINT51264–16384

Outputs (1)

NameTypeDescription
IMAGEIMAGE