Edge Detection (Purz)
Sobel, Canny, Laplacian in one node
- image
- image
Edge detection is one of those things everyone uses for ControlNet and nobody wants to think about. PurzEdgeDetect gives you the three classic algorithms - Sobel, Canny, Laplacian - behind a single dropdown, so you can find the one that gives you the cleanest linework for your particular image without installing a second pack. In, IMAGE; out, an edge map as a normal IMAGE you can pipe into a controlnet preprocessor slot or just look at.
It's from ComfyUI-Purz, the utility pack by PurzBeats (a Comfy Org staffer). No models, no downloads - this is pure OpenCV math.
How it works
Every method starts the same way: the image is converted to grayscale, then the chosen algorithm runs on it. The differences are what you'd expect from the classic literature:
- Sobel - computes the gradient in x and y, then combines them (
sqrt(Gx² + Gy²)) to get edge strength. This is the "everything, including faint stuff" option. It doesn't threshold, so you get soft gradients rather than crisp lines. - Canny - a proper multi-stage detector with hysteresis thresholding. This is the one that produces clean, thin, confident lines, and it's the one you'll actually want for most ControlNet linework.
- Laplacian - a second-derivative operator that's very sensitive. It catches everything, including noise, so it tends to look busy.
An important detail: the threshold_low and threshold_high inputs only matter when method is canny. Sobel and Laplacian ignore them entirely - so don't reach for those sliders expecting them to tune a Sobel result. Canny uses them as its low/high hysteresis bounds, which is exactly how Canny's thresholds work in every tool.
The inputs that matter
- image - the
IMAGEto process. Works across a batch, so a whole frame sequence is fine. - method -
sobel,canny, orlaplacian. Default is sobel; switch tocannyfor clean lines. - threshold_low - 0–255, default 50. Canny's low threshold.
- threshold_high - 0–255, default 150. Canny's high threshold. The gap between them is your "confidence" band - a wide gap catches more, a narrow one is stricter.
Output is image, an IMAGE (edge map expanded back to RGB so it drops into any image slot). It's grayscale-looking, but it's a 3-channel tensor like everything else.
Installing it
ComfyUI Manager - search ComfyUI-Purz - or:
cd ComfyUI/custom_nodes/
git clone https://github.com/purzbeats/ComfyUI-Purz.git
cd ComfyUI-Purz
pip install -r requirements.txt
Restart ComfyUI. Requirements are OpenCV, Pillow, torch, numpy - the OpenCV dependency is doing all the heavy lifting here, and you already have it.
Where people get burned
The number one trap is feeding Canny a busy, low-contrast image and getting either a wall of noise or nothing at all - the fix is always the thresholds, not the method. Start with the 50/150 defaults and move them together (both down for more edges, both up for fewer). And remember this is a raw edge detector, not a ControlNet preprocessor - it doesn't know about aspect ratios or model expectations, so if you're feeding it into ControlNet you may still want the dedicated preprocessor node afterward. For a quick, dependency-free edge map, though, it's hard to beat.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| method | COMBO | sobel | 3 options: sobel, canny, laplacian |
| threshold_low | FLOAT | 500–255 | — |
| threshold_high | FLOAT | 1500–255 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |