ComfyUI Node

Edge Detection

Edge detection with texture work in mind, not ControlNet prep

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Edge Detection
  • image
  • edges
method
strength1.0
threshold0.10
invertfalse

You probably know edge detection from ControlNet preprocessors - Canny, Sobel, the stuff that feeds structural guides into a diffusion model. This node is the same family of math pointed at a different job: instead of prepping an image for a ControlNet, it's generating edge/curvature-style masks for your material pipeline. In PBR terms, edges are where wear happens - paint chips off corners, metal scuffs at creases - so an edge mask is the fuel for weathering, not just a filter that makes your texture look like a sketch.

The node gives you five classic operators via the method dropdown, all implemented with plain PyTorch convolutions:

  • sobel - the balanced default; good all-round edge response
  • scharr - a stronger approximation of the same gradient, tighter and more sensitive; the one the pack's docs point you to when you want sharper detail for wear masks
  • prewitt - a slightly smoother, more forgiving variant
  • laplacian - second-derivative edge detection, which catches edges from all directions at once and tends to produce double-edged outlines; good for finding intensity transitions rather than oriented edges
  • canny_approx - a simplified Canny (Gaussian blur then Sobel), the most "clean line" output of the bunch

Every method operates on the grayscale luminance, then you shape the result with the knobs: strength scales the response, threshold keeps only edges above a cutoff (0 = everything, 1 = only the strongest - this is the knob that turns noise into clean lines), and invert flips the mask so white becomes background and edges go black. Output is a single edges IMAGE.

Where this fits the pack: the README's own recipe is Curvature generator → Wear generator for edge wear, and Edge Detection is effectively the same ingredient in loose form. Run it on a height or normal-derived map, threshold it to isolate just the sharp boundaries, and you've got a mask that says "wear happens here." Multiply it into your albedo as a darkening edge, add it to roughness as scuffing, or feed it into the Detail Map Blender's mask input to restrict detail to edges.

If you do want to use it as a ControlNet prep you can, but that's not the strength here - the preprocessors in packs like ControlNet Auxiliary are tuned for that and come with more options. This node is for generating masks that make materials look used.

Install is pack-standard: Manager → search "Texture Alchemy", or:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart, then Texture Alchemist/Filters → Edge Detection. No dependencies, no model files - all of it is fixed convolution kernels. Watch the shared gotchas: the README's copy step uses the pack's old folder name, and a blocked Git-URL install means the security level is up - clone manually.

CategoryTexture Alchemist/Filters

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
methodCOMBO5 options: sobel, scharr, prewitt, canny_approx, laplacian
strengthFLOAT1.00–3
thresholdFLOAT0.100–1Edge threshold (0=all, 1=strong only)
invertBOOLEANfalse

Outputs (1)

NameTypeDescription
edgesIMAGE