Nodes/ComfyUI-BrainDead/BD Normalize Luma
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.

By BizaNator·Created 7 months ago·Updated 16 days ago· 14
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)

NameTypeDefaultDescription
imageIMAGESource image to normalize.
luma_standardCOMBObt709RGB → 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_maxFLOAT0.950–1Brightest output value. Set lower (e.g. 0.85) to compress an over-bright image so there's headroom.
target_minFLOAT0.000–1Darkest output value. Set higher (e.g. 0.1) to lift shadows in an under-exposed image.
clip_percent_highFLOAT1.00–50Treat 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_lowFLOAT1.00–50Treat the bottom X% of valid pixels as the source-min. Higher values ignore more outliers.
preserve_colorBOOLEANtrueON: rescale RGB proportionally (keeps color, just darkens/brightens). OFF: convert to greyscale using the normalized luma.
proportional_scaleBOOLEANfalseOFF (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_onlyBOOLEANtrueON (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.
maskoptMASKOptional 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_minoptFLOAT0.000–1Tone 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_maxoptFLOAT1.000–1Tone 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_featheroptFLOAT0.150–1Soft 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)

NameTypeDescription
imageIMAGENormalized image (RGB preserved if preserve_color=on).
found_minFLOATThe source luma value that maps to target_min.
found_maxFLOATThe source luma value that maps to target_max.