Countour Mask Regions Extraction
Trace a mask's outline to clean up noisy segmentation
- masks
- MASKS
Countour Mask Regions Extraction (yes, that's a typo in the pack's own class naming, "Countour" for "Contour" - it happens) finds the outline of whatever's in your mask and redraws it as a clean, filled shape. It's genuinely useful for cleaning up a noisy or speckled mask: instead of trying to smooth away stray pixels one at a time - which is what a bilateral filter does gradually - this node traces the actual silhouette and gives you back a solid region bounded by that outline, discarding disconnected noise that isn't part of the main shape.
How it works
This is the classic "find contours, keep the boundary" operation - OpenCV's findContours-style tracing, applied to your mask after a binarization step. thresholds is the cutoff it applies before tracing: same 8-bit scale as any other mask threshold, deciding what counts as "in" before the contour search runs.
The inputs and outputs that matter
masks(required, MASK).thresholds(optional, default 128, 0–255) - the binarization cutoff applied before contour-finding. Raise it if your source mask is faint and stray pixels are getting picked up as spurious contours; lower it if real detail is getting thresholded away before the contour search even starts.
Output is MASKS - a contour-cleaned region.
How to install it
ComfyUI Manager: search SaltAI-Open-Resources or SaltAI, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/get-salt-AI/SaltAI
then restart. OpenCV-backed (findContours is a core cv2 function) - cv2 should already be available if the rest of this pack's mask filters are working for you.
Common issues & troubleshooting
A second region that should have survived is missing. The schema doesn't specify whether this node keeps just the largest/dominant contour or every contour it finds. Test it explicitly on a mask with two genuinely separate regions before assuming it behaves the way you want - if it's dropping one, that mismatch between what you expected and what the node actually does is the likely explanation, not a bug.
Lots of tiny spurious contours instead of one clean shape. Speckled input masks with a lot of small, disconnected noise blobs tend to produce a lot of tiny contours rather than one solid one. Running SaltMaskDilateRegion or SaltMaskBilateralFilter first, to consolidate the noise before contour-finding, tends to help a lot here.
Real detail got smoothed away. If thresholds is set too high relative to how faint your source mask is, genuine detail can get thresholded out before the contour search even sees it - lower it and re-run.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | — | |
| thresholdsopt | INT | 1280–255 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASKS | MASK | — |