Nodes/ComfyUI-Light-Tool/Light-Tool: MaskContourExtractor
ComfyUI Node

Light-Tool: MaskContourExtractor

Outline your mask's edges in any color — but read the fine print

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: MaskContourExtractor
  • image
  • image
color_hex#FF0000
use_hextrue
R255
G255
B255

Masks are great until you need to see their boundaries. Light-Tool: MaskContourExtractor takes a mask image and draws its outer contours back onto it in a color you choose - the visual equivalent of outlining the shape before you decide what to do with it. If you're sanity-checking a segmentation mask or building edge-based inputs, this turns an abstract white blob into something you can actually inspect.

Inputs: image (required), plus color controls - color_hex (default #FF0000, red), a use_hex toggle, and R/G/B ints (0–255) for when you'd rather type raw RGB than hex. Output: one image.

How it works. The image is flattened to grayscale and thresholded at a fixed level (127) to produce a binary mask. OpenCV's findContours with the external-retrieval mode then traces the outer boundaries, and drawContours paints them back in your chosen color at 1-pixel thickness. The output is the grayscale image with the contour outlines overlaid.

The fine print - and it's important. The node description says "extract contour points," and the code genuinely does compute the point lists - but they are not returned. The only output is the annotated image. If you were hoping for coordinates to feed a crop-and-paste loop or a path builder, this node won't hand them over. It's a visualization node wearing a slightly misleading description.

Three more things are baked in and not tunable: the threshold is hardcoded at 127 (no slider), the line thickness is hardcoded at 1px (thin, and possibly faint on noisy masks), and the input is converted to grayscale - so whatever colors your mask had are gone by the time contours get drawn. For a clean binary mask none of this matters. For a soft-edged or noisy one, you'll want to clean it up (the pack's MorphologicalTF is the natural pre-step) before the threshold picks garbage.

When it's useful. Debugging segmentation masks from models like SAM or BiRefNet - a colored outline makes a misshapen edge instantly obvious. It's also a plausible stepping stone for edge-conditioning experiments (the outline itself can feed a ControlNet-style edge condition if that's your jam). Mostly though, this is an inspection tool, and it's honest about being one.

Installing. Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/ihmily/ComfyUI-Light-Tool.git
pip install -r requirements.txt
# restart ComfyUI

Or ComfyUI Manager → search ComfyUI-Light-Tool → Install. No models; it's OpenCV under the hood.

Verdict: handy for eyeballing masks, not for extracting geometry. Want the outline drawn? Great. Want the points? This node teases you with its description - the image output is all it gives you.

CategoryComfyUI-Light-Tool/image/ImageInfo

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
color_hexSTRING#FF0000
use_hexBOOLEANtrue
RINT2550–255
GINT2550–255
BINT2550–255

Outputs (1)

NameTypeDescription
imageIMAGE