Advanced Luminance Mask β‘π ‘π π £π
Cut out a subject by brightness, no segmentation model needed
- image
- MASK
- IMAGE
Sometimes you don't need a full segmentation model to get a usable mask - you just need "everything that isn't the background." If your subject and background sit at noticeably different brightness levels, this node gets you there without loading anything heavier than the image itself.
One of ryanontheinside's standalone mask utilities, sitting outside the FlexFeatures and ACE-Step sides of the pack.
How it works
It samples several corners of the image (background_samples, default 10) to work out what the background actually looks like, then thresholds every pixel against that using luminance_threshold - lower values catch subtler detail, higher ones only flag strongly different pixels. A glow_radius softens the resulting edges outward for a gentler mask boundary, edge_preservation trades that softness off against keeping sharp detail where it exists, and denoise_strength smooths out noisy speckling in the final result. All of this comes straight from the node's own tooltips, which are unusually thorough for a ComfyUI node.
The inputs and outputs that matter
image- the only required non-numeric input, your sourceIMAGE.luminance_threshold- default 0.05. The main dial: drop it if you're missing subtle detail near the edges of your subject, raise it if the mask is grabbing background it shouldn't.glow_radius- default 5 pixels. Higher gives a larger, softer glow around detected edges.background_samples- default 10. More samples generally means a more accurate read on what "background" actually is, useful if your backdrop isn't perfectly flat.
Outputs are MASK (the mask itself) and IMAGE - a visual you can drop straight into a preview node to eyeball the result without adding a separate preview step.
How to install it
Via ComfyUI Manager, search RyanOnTheInside. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ryanontheinside/ComfyUI_RyanOnTheInside
then restart. No models to fetch - it's plain image math.
Common issues & troubleshooting
Mask grabs way more than the subject. Usually means the background isn't uniform enough for corner sampling to characterize it well. Try raising background_samples first, or lower luminance_threshold if the issue is actually subtle-detail loss rather than background contamination.
Edges look blobby or over-glowed. Bring glow_radius down toward 0, or raise edge_preservation to keep more of the original edge sharpness.
This isn't a replacement for real segmentation. It has zero semantic understanding - it only knows about brightness. On a busy scene with a similarly-lit subject and background, or anything where "the subject" isn't also "the bright part," reach for an actual segmentation node (rembg, SAM) instead. This one shines on simple setups: a lit subject on a dark backdrop, a glowing element, that kind of contrast.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to create mask from (IMAGE type) | |
| luminance_threshold | FLOAT | 0.050β1 | Base threshold for detecting non-background elements (0.0 to 1.0). Lower values catch more subtle details. |
| glow_radius | INT | 50β50 | Size of the glow effect in pixels (0 to 50). Higher values create larger, softer glows. |
| edge_preservation | FLOAT | 0.500β1 | How much to preserve sharp edges while allowing glow (0.0 to 1.0). Higher values maintain more edge detail. |
| background_samples | INT | 101β100 | Number of corner samples to determine background color (1 to 100). More samples give better background detection. |
| denoise_strength | FLOAT | 0.300β1 | Strength of noise reduction (0.0 to 1.0). Higher values smooth out noise while preserving edges. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | β |
| IMAGE | IMAGE | β |