Nodes/ComfyUI LC MaskMaker Nodes/LC Touch Mask (BETA) πŸ‘†
ComfyUI Node

LC Touch Mask (BETA) πŸ‘†

Drawing the Mask You Actually Meant

By lonecatone23Β·Created 2 months agoΒ·Updated a day agoΒ· 18
LC Touch Mask (BETA) πŸ‘†
  • image
  • control_image
  • control_mask
β—„sam3_modelβ–Ύβ–Ί
β—„person_partsβ–Ύβ–Ί
β—„blockfalseβ–Ί
β—„grow0β–Ί
β—„feather0.0β–Ί
β—„invertfalseβ–Ί
β—„selections[]β–Ί
β—„threshold0.50β–Ί
β—„smooth2β–Ί
β—„refineguided_filterβ–Ί

What it is

A mask node you operate with your finger instead of a careful spline. Draw a rough circle around the thing and SAM 3 snaps to its actual edges. Then tap it, and the selection grows to the next bigger thing containing it - face, face plus hair, head, whole person. Double-tap steps back down.

It fills an awkward gap. LC Create Mask gives you a hand-drawn shape and no idea what a face is; LC Segment Anything makes you describe the target and hope SAM 3 agrees. Sometimes you know exactly which of eleven bag-shaped blobs you want. The author credits the stroke-to-prompt idea to AusBoss' Mask by Touch (MIT).

How it works

Your lasso isn't sent to SAM as a mask - it becomes a box plus an inner point, which is the prompt shape SAM's decoder takes. The result is then clipped to the lasso grown by 2% of the image diagonal, so the segmentation never swallows the sofa behind the thing you circled.

Tapping searches for the next larger enclosing thing. The node renders candidates - SAM's own alternative answers for that point, plus boxes scaled 1.5Γ—, 2.2Γ— and 3.2Γ— around the current selection - and only accepts a step that's at least 15% bigger and still holds at least 60% of the current selection. Only parts touching what you already have get kept, so a step never jumps to a separate object. Tapping a face gives you a head, not a head and a lamp.

On a person, taps can climb body parts instead. With person_parts on, growth comes from the Segformer model LC Person Mask uses, on a fixed ladder: face β†’ face + hair β†’ head β†’ top β†’ clothes β†’ person. That beats a geometric grow, because it knows where hair ends and jacket begins.

Each selection is stored as a recipe in the selections widget, and the run rebuilds it at full resolution. The preview is a preview; the output is native pixels. Undo and Clear sit on the node.

The inputs worth setting

  • image - a Load Image upstream shows immediately; anything else (a render, an upscale) needs one queue for the preview to catch up.
  • person_parts - off by default. On for humans, but note segformer_b2_clothes carries a license of other: check it before commercial use.
  • refine - guided_filter by default (fast, follows the picture's edges), vitmatte for hair at a speed cost, none for the hard selection. Applied on the run, so the preview shows the selection before it.
  • grow / feather / invert - pixels in or out, edge softness, flip to everything-but.
  • threshold (0.5) and smooth (2) - how sure a pixel must be to join, and how much pinhole-filling and speck-dropping to do. smooth doesn't shrink the selection, which is why it's worth leaving above zero.
  • block - downstream stops while nothing is selected, so you can draw a mask and queue again, Preview Bridge style.

Outputs are control_image and control_mask, the same pair LC Create Mask emits, so it drops into an inpaint or AnyPaint group without rewiring. That's what the author built it for: masking one object by hand for the detailers.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/lonecatone23/ComfyUI_LC_MaskMaker_nodes
# restart ComfyUI

Or ComfyUI_LC_MaskMaker_nodes through ComfyUI Manager, then restart. Two dependencies worth naming up front:

  • A ComfyUI with built-in SAM 3. Otherwise you get "This ComfyUI has no built-in SAM 3 support. Update ComfyUI." The model is 1.7 GB into models/sam3 on first use.
  • OpenCV. The node imports cv2, and the pack's install.py deliberately installs only transformers, huggingface_hub and timm when missing - never torch, numpy or Pillow. So cv2 has to be importable already. Most installs have it via another pack; if this node errors on load, that's your suspect.

Common issues

The tap grew to the wrong thing. Double-tap to walk back down the ladder; at the first step it removes the selection. Non-person subjects have no body-part ladder, so growth is purely geometric and a tap may find a table instead of a shoulder.

The preview shows nothing. Only a Load Image upstream renders immediately. Everything else needs one run first.

The selection shifts when you change threshold. It's re-deciding the segmentation under your already-chosen growth steps. Set threshold first, then tap.

Mask is the wrong way round. invert is a plain widget and easy to leave on from the last job. Check it before anything else.

CategoryLC MaskMaker/mask

Inputs (11)

NameTypeDefaultDescription
imageIMAGEPicture to mask. A Load Image upstream shows up right away, anything else after one run.
sam3_modelCOMBOFinds the edges. The same SAM 3 model LC Segment Anything and LC Smart Detailer use.
person_partsCOMBOOn a person, taps grow by body part (face, hair, head, clothes, person) with the Segformer model LC Person Mask uses. off: SAM 3 decides every step.
blockBOOLEANfalseif_empty_mask: when nothing is selected, or a new picture comes in from a run, everything downstream stops so you can select on the picture shown, then Run (with LC123 it carries on with the same seeds). A new picture in a Load Image shows here right away, so it doesn't stop.
growINT0-256–256Grow (or shrink, below 0) the finished mask by this many pixels.
featherFLOAT0.00–200Edge softness in pixels.
invertBOOLEANfalseFlip the mask (everything but the selection).
selectionsSTRING[]Internal: what you drew and tapped.
thresholdFLOAT0.500.05–0.95How sure a pixel must be to join. Lower takes in more (wispy hair, soft edges), higher is tighter.
smoothINT20–16Cleans the edge: fills pinholes, drops stray specks and rounds jagged edges, without shrinking the selection. 0 = raw.
refineCOMBOguided_filterEdge finish on the run (the preview shows the selection before it). guided_filter: fast, follows the picture's edges. vitmatte: best for hair, slower. none: the hard selection.

Outputs (2)

NameTypeDescription
control_imageIMAGEβ€”
control_maskMASKβ€”