Mask_simple_adjust
Cleaning up and reshaping masks in ComfyUI
- input_mask
- processed_mask
A raw mask straight out of a segmentation or SAM node is rarely exactly what you want for inpainting - edges are usually too hard, coverage is a pixel or two short of where you actually want the blend to happen, and stray holes or noise show up more often than you'd like. Mask_simple_adjust is cardenluo's ComfyUI-Apt_Preset cleanup node for exactly that gap between "raw mask" and "mask that inpaints cleanly."
What it does
It's a grab-bag of mask post-processing operations applied in one node instead of chaining several single-purpose ones. smoothness feathers the mask edge (0–150) - higher values give you a softer blend at the boundary instead of a hard cutout line. mask_expand grows or shrinks the masked region by a pixel amount, negative values shrinking, positive growing - the standard "grow mask" / "shrink mask" operation you'd otherwise reach for a separate node to do. is_fill fills interior holes in the mask (useful when a segmentation model leaves gaps inside a region that should be solid), and is_invert flips foreground and background.
mask_min and mask_max remap the mask's value range - think of it as a levels adjustment applied to the mask's grayscale values rather than to an image's brightness, useful for pushing a soft, low-contrast mask toward fully black-and-white or, conversely, softening a hard mask's edges into a gradient. threshold binarizes the mask at a cutoff, turning a soft/probabilistic mask into a hard yes/no one. extract_to_block with block_size breaks the mask into blocky, tile-sized regions rather than a smooth continuous shape - useful for mosaic-style effects or coarse, grid-aligned selections. output_max_mask is worth testing on your own masks to confirm its exact behavior before relying on it in a pipeline - going by the name, it likely isolates just the largest region when your mask has multiple disconnected blobs, but confirm that against your own output rather than assuming.
Inputs and outputs
Required: input_mask (MASK), smoothness (0–150), mask_expand (-500 to 1000), is_fill, is_invert, mask_min (default 0), mask_max (default 1), extract_to_block, block_size (0–500), output_max_mask, threshold (0–1).
Single processed_mask output.
Most beginners will only ever touch three of these: mask_expand to grow a mask slightly before inpainting (a couple pixels of headroom around the edge usually blends better than a mask that stops exactly at the subject), smoothness to soften a hard-edged mask, and threshold if you're feeding in a soft mask somewhere that expects a binary one.
Where this fits
This is the node to insert right before an inpaint or compositing step whenever your mask came from something automated (a segmentation model, SAM, a detector) rather than being hand-painted - automated masks are consistently a little too tight, a little too hard-edged, or a little too noisy to use raw, and this node fixes all three in one pass instead of three separate nodes.
Installing it
Through ComfyUI Manager: search ComfyUI-Apt_Preset. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
Run install.bat (Windows) or install requirements.txt yourself, restart ComfyUI. No external models needed - this is mask math only.
Troubleshooting
If the node's missing, check for a pack-wide import failure first - ComfyUI-Apt_Preset is large and there's a documented IMPORT FAILED report for it; check the ComfyUI console at startup for the real error.
For this node specifically: if your mask disappears entirely after processing, check threshold first - a threshold set too high on a soft mask will zero it out completely, which reads as "the node broke" when it's actually doing exactly what the setting says. If mask_expand seems to do nothing, confirm you're not also running extract_to_block at the same time - the blocky reshaping from that setting can visually swamp a small expand value, so isolate one adjustment at a time when you're first dialing this node in rather than changing several settings at once.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| smoothness | INT | 00–150 | — |
| mask_expand | INT | 0-500–1000 | — |
| is_fill | BOOLEAN | false | — |
| is_invert | BOOLEAN | false | — |
| input_mask | MASK | — | |
| mask_min | FLOAT | 0.00-10–1 | — |
| mask_max | FLOAT | 1.000–10 | — |
| extract_to_block | BOOLEAN | false | — |
| block_size | INT | 00–500 | — |
| output_max_mask | BOOLEAN | false | — |
| threshold | FLOAT | 0.0000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| processed_mask | MASK | — |