LC Touch Mask (BETA) π
Drawing the Mask You Actually Meant
- image
- control_image
- control_mask
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 -
offby default. On for humans, but notesegformer_b2_clothescarries a license of other: check it before commercial use. - refine -
guided_filterby default (fast, follows the picture's edges),vitmattefor hair at a speed cost,nonefor 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.
smoothdoesn'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/sam3on first use. - OpenCV. The node imports
cv2, and the pack'sinstall.pydeliberately installs onlytransformers,huggingface_hubandtimmwhen missing - never torch, numpy or Pillow. Socv2has 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.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Picture to mask. A Load Image upstream shows up right away, anything else after one run. | |
| sam3_model | COMBO | Finds the edges. The same SAM 3 model LC Segment Anything and LC Smart Detailer use. | |
| person_parts | COMBO | On 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. | |
| block | BOOLEAN | false | if_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. |
| grow | INT | 0-256β256 | Grow (or shrink, below 0) the finished mask by this many pixels. |
| feather | FLOAT | 0.00β200 | Edge softness in pixels. |
| invert | BOOLEAN | false | Flip the mask (everything but the selection). |
| selections | STRING | [] | Internal: what you drew and tapped. |
| threshold | FLOAT | 0.500.05β0.95 | How sure a pixel must be to join. Lower takes in more (wispy hair, soft edges), higher is tighter. |
| smooth | INT | 20β16 | Cleans the edge: fills pinholes, drops stray specks and rounds jagged edges, without shrinking the selection. 0 = raw. |
| refine | COMBO | guided_filter | Edge 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)
| Name | Type | Description |
|---|---|---|
| control_image | IMAGE | β |
| control_mask | MASK | β |