ComfyUI Node
BD Normalize Luma
Auto-rescale image luma to a target range. Uses percentile clipping so outlier pixels (e.g. saturated highlights, dead-black background) don't define the source range. Optional mask restricts the percentile calc to a region (e.g. skin only). Useful as a preprocess before BD_LuminanceMask when the source is too bright/dark and the percentile collapses.
BD Normalize Luma
- image
- mask
- image
- found_min
- found_max
◄luma_standardbt709►
◄target_max0.95►
◄target_min0.00►
◄clip_percent_high1.0►
◄clip_percent_low1.0►
◄preserve_colortrue►
◄proportional_scalefalse►
◄apply_to_mask_onlytrue►
◄luma_apply_min0.00►
◄luma_apply_max1.00►
◄luma_apply_feather0.15►
Category🧠BrainDead/Segmentation
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Source image to normalize. | |
| luma_standard | COMBO | bt709 | RGB → luminance weighting: bt709 (default): 0.2126 R + 0.7152 G + 0.0722 B — modern sRGB/Rec.709 standard. Use for Unity/Unreal, AI pipelines, modern display work. bt601: 0.299 R + 0.587 G + 0.114 B — legacy NTSC weights, matches Photoshop 'Desaturate' and older tools. average: (R+G+B)/3 — simple, not perceptual. |
| target_max | FLOAT | 0.950–1 | Brightest output value. Set lower (e.g. 0.85) to compress an over-bright image so there's headroom. |
| target_min | FLOAT | 0.000–1 | Darkest output value. Set higher (e.g. 0.1) to lift shadows in an under-exposed image. |
| clip_percent_high | FLOAT | 1.00–50 | Treat the top X% of valid pixels as the source-max. Higher values ignore more outliers. 1.0 = robust default. 0 = use absolute max (sensitive to single-pixel spikes). |
| clip_percent_low | FLOAT | 1.00–50 | Treat the bottom X% of valid pixels as the source-min. Higher values ignore more outliers. |
| preserve_color | BOOLEAN | true | ON: rescale RGB proportionally (keeps color, just darkens/brightens). OFF: convert to greyscale using the normalized luma. |
| proportional_scale | BOOLEAN | false | OFF (default): RANGE FIT — remaps source [min, max] to target [min, max]. Stretches/compresses both ends, lifts or drops the black floor. ON: PROPORTIONAL — single multiplier (target_max / src_max), then HARD CLAMP at target_max. No pixel can exceed target_max. Brightest non-outlier pixel hits exactly target_max, outlier pixels (top clip_percent_high%) are clamped down to target_max. Everything below scales by the same factor, input=0 stays at 0. target_min is IGNORED. Use when you want to dim the whole image without lifting shadows — e.g. shift brightest part down to mid-grey (target_max=0.5) — even saturated pixels are guaranteed ≤ 0.5. |
| apply_to_mask_only | BOOLEAN | true | ON (default): only pixels WITHIN the mask are normalized — pixels outside the mask pass through UNCHANGED from the source. OFF: normalization is applied to the whole image, even outside the mask area (mask still controls the percentile calc either way). If no mask is wired, this setting has no effect. |
| maskopt | MASK | Optional region mask. Percentile calc only considers pixels where mask > 0.5. By default (apply_to_mask_only=ON), the normalization is also only applied within this region. | |
| luma_apply_minopt | FLOAT | 0.000–1 | Tone floor — normalization fades out BELOW this luminance. 0.0 = apply to all tones (default, existing behaviour). 0.5 = only pixels at or above mid-grey receive the full normalized result; darker pixels fade back to original. Use this to bring down highlights without touching shadows. Combined with luma_apply_max to target a tone band: luma_apply_min=0.6, luma_apply_max=1.0 → highlights only luma_apply_min=0.0, luma_apply_max=0.5 → shadows only luma_apply_min=0.3, luma_apply_max=0.7 → midtones only |
| luma_apply_maxopt | FLOAT | 1.000–1 | Tone ceiling — normalization fades out above this luminance. 1.0 = apply to all tones (default, existing behaviour). 0.5 = only pixels at or below mid-grey receive the full normalized result; brighter pixels fade back to original. Use this to lift shadows without touching highlights. |
| luma_apply_featheropt | FLOAT | 0.150–1 | Soft transition width applied to BOTH the floor (luma_apply_min) and ceiling (luma_apply_max) edges. 0 = hard cutoff. 0.15 = blend ramps over 0.15 luma units at each edge (recommended). Blend is always computed from ORIGINAL luma so the result doesn't chase the output — a highlight stays a highlight. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | Normalized image (RGB preserved if preserve_color=on). |
| found_min | FLOAT | The source luma value that maps to target_min. |
| found_max | FLOAT | The source luma value that maps to target_max. |