Nodes/BrainDead Nodes/BD Luma Stats
ComfyUI Node

BD Luma Stats

A ruler for your greys — measure luminance so your shading pipeline actually hits its targets

By BizaNator·Created 8 months ago·Updated 3 days ago· 15
BD Luma Stats
  • image
  • mask
  • image
  • min_luma
  • max_luma
  • median_luma
  • mean_luma
  • recommended_outer_band
luma_standardbt709

BD Luma Stats doesn't change a single pixel. It measures the image it's given and reports numbers - and that's exactly why you reach for it. If you're doing game-texture prep or any shading pipeline where you normalize luminance before packing channels, you're flying blind without it. This is the node that tells you whether your normalization actually normalized.

It slots into the BrainDead pipeline that turns a character render into engine-ready maps: you normalize luma (BD Normalize Luma), you center the median (BD Center Median Luma), you maybe drive a GLSL shader uniform. All of those nodes take target values - 0.1 for the low point, 0.9 for the high, 0.5 for the center - and BD Luma Stats is the instrument you wire inline to verify they landed. The node brief itself says it plainly: min_luma should ≈ NormalizeLuma low_point, max_luma should ≈ high_point, median should ≈ CenterMedianLuma target_center. If those don't match, your downstream maps are built on a foundation that isn't what you think it is.

How it works

Luminance is computed from RGB with a weighting standard you pick:

  • bt709 (default) - 0.2126 R + 0.7152 G + 0.0722 B, the modern sRGB/Rec.709 standard. Use this for Unity/Unreal and anything current.
  • bt601 - legacy NTSC weights, matches Photoshop's "Desaturate."
  • average - plain (R+G+B)/3, simple and not perceptual.

The stats are computed over the region your mask selects. That optional mask is the most important input on this node: wire your skin mask (or the region you actually care about) so background and clothing can't drag the numbers around. Unmasked, a dark background will wreck your median readout and you'll "fix" a problem that isn't one.

The output that looks cryptic - recommended_outer_band - is the one that's actually useful. It's (max − min)/2 × 0.90, and it's meant to be pasted straight into the u_float2 uniform in BD GLSLBatch. The 0.9 factor means the extreme ~10% of pixels fall outside the band and reach full alpha in the shader, so your highlights and shadows have visible depth instead of flattening out. The README's own guidance: when you wire BD Luma Stats inline in the grey-source pipeline, you're both verifying the normalizers and computing the shader constant at once. One node, two jobs.

The image output is a pass-through - the source image comes out unchanged, so you can drop this node inline in a chain without forking your graph to an extra branch. And the mean_luma output pairs with median_luma as a diagnostic: if the two are far apart, your luminance distribution is skewed (lots of dark with a few brights, or vice versa), which tells you a simple min/max remap may not be the right fix.

Installing

Same as the whole pack - ComfyUI Manager, search "BrainDead", install; or:

cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt

Then restart. The pack needs a reasonably recent ComfyUI because every node uses the V3 API.

The trap to avoid

The most common mistake is measuring the wrong pixels - no mask, or a mask that includes the background. The second is assuming the numbers are right and never checking the mean vs median gap. This is a diagnostics node; treat it like a multimeter. It earns its place by being wired in while you build the pipeline, not bolted on after something looks wrong.

Category🧠BrainDead/Segmentation

Inputs (3)

NameTypeDefaultDescription
imageIMAGESource image. Passed through to the image output unchanged.
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.
maskoptMASKOptional region mask. When connected, stats are computed only from pixels where mask > 0.5. Strongly recommended: use your skin mask so background and clothing don't bias the measurements.

Outputs (6)

NameTypeDescription
imageIMAGEPass-through — image is unchanged.
min_lumaFLOATDarkest pixel luma in the masked region. Should ≈ BD_NormalizeLuma low_point (e.g. 0.10).
max_lumaFLOATBrightest pixel luma in the masked region. Should ≈ BD_NormalizeLuma high_point (e.g. 0.90).
median_lumaFLOATMedian luma. Should ≈ BD_CenterMedianLuma target_center (e.g. 0.50).
mean_lumaFLOATMean luma. Compare with median — large gap means a skewed distribution.
recommended_outer_bandFLOAT(max−min)/2 × 0.90. Paste into u_float2 in BD_GLSLBatch. The ×0.90 factor ensures the extreme ~10% of pixels exceed the outer band and reach V-curve alpha=1.0, giving the shader visible shadow/highlight depth.