Nodes/SaltAI-Open-Resources/Edge Detect Mask Regions
ComfyUI Node

Edge Detect Mask Regions

Turn a filled mask into just its outline

By get-salt-AI·Created 2 years ago·Updated 2 years ago· 84
Edge Detect Mask Regions
  • masks
  • MASKS
method
low_threshold50
high_threshold150
sobel_ksize5

Most mask-filter nodes reshape the filled area of a mask. SaltMaskEdgeDetection does something different - it runs a classic computer-vision edge detector on the mask itself, turning a solid filled blob into just its boundary line.

What it does

You get a method choice between two well-known algorithms: sobel and canny. Sobel is gradient-based edge detection - it measures how sharply values change across the mask and highlights those transitions; sobel_ksize (1–7, default 5) controls the size of the kernel it uses, which trades sensitivity against smoothing. Canny is the standard two-threshold edge detector: low_threshold and high_threshold (0–255, defaults 50 and 150) set the hysteresis bounds Canny uses to decide what counts as a real edge versus noise - a pixel above the high threshold is definitely an edge, a pixel below the low threshold definitely isn't, and anything in between only counts if it connects to a confirmed edge. Note that low_threshold/high_threshold only really matter when you've picked canny, and sobel_ksize only matters for sobel - the node exposes both algorithms' parameters at once even though only one set is actually in play depending on your method choice. The output, MASKS, is the outline.

Where you'd use this

Anywhere you want a boundary/contour instead of a filled region: building a thin "ring" mask around a subject (pair the output with SaltMaskAdd or a dilate/erode combo to thicken it into an actual band rather than a single-pixel line), generating edge-aware data from a mask for a compositing effect, or visualizing exactly where a mask's boundary sits without the filled interior obscuring it.

Installing it

ComfyUI Manager: search SaltAI-Open-Resources. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/get-salt-AI/SaltAI

Restart ComfyUI. Standard OpenCV-style operations under the hood, no model weights involved.

Common issues

With Canny, a threshold gap that's too tight produces broken, fragmented edges - real boundaries get cut into disconnected segments because too few pixels qualify as "definitely an edge" to link the weaker ones together. Too wide a gap does the opposite: it lets noise through as false edges. The classic tuning move is to widen or narrow the gap between low_threshold and high_threshold and check the result visually rather than guessing at values blind. With Sobel, a larger sobel_ksize smooths more before detecting, which can blur out fine detail in a small or intricate mask - if you're losing detail you expect to see, try a smaller kernel size. And since this node operates on the mask's values, not the underlying image, feed it a clean, already-processed mask (threshold or smooth it first if it's noisy) - running edge detection on a rough, speckled mask just gives you a rough, speckled outline.

CategorySALT/Masking/Filter

Inputs (5)

NameTypeDefaultDescription
masksMASK
methodCOMBO2 options: sobel, canny
low_thresholdINT500–255
high_thresholdINT1500–255
sobel_ksizeINT51–7

Outputs (1)

NameTypeDescription
MASKSMASK