Nodes/ComfyUI-JH-PixelPro/Luminosity Masking
ComfyUI Node

Luminosity Masking

Select by Brightness, Not by Shape

By jetthuangai·Created 5 months ago·Updated 4 months ago· 5
Luminosity Masking
  • image
  • mask_shadows
  • mask_midtones
  • mask_highlights
luminance_sourcelab_l
shadow_end0.33
highlight_start0.67
soft_edge0.10

Luminosity masks are one of those Photoshop tricks that feel like cheating the first time you use them. Instead of selecting an object by shape, you select by brightness - pull a mask that covers only the shadows, or only the highlights, and grade that band without touching anything else. JHPixelProLuminosityMasking brings exactly that to ComfyUI, and it does it properly: the three bands sum to ~1.0 at every pixel (a partition of unity), so shadows + midtones + highlights ≈ 100% with no gaps and no double-counting.

Why you'd reach for it: split-tone grading (push warm into the shadows only), denoising just the dark regions where the noise actually lives, or a subtle local-contrast bump in the midtones. It's a mask generator, so the output feeds any mask consumer - an ImageBlend, a LUT apply, a compositor, a SetLatentNoiseMask. Selection by luminance band, not by shape, is the whole game.

How it works: the node computes a luminance channel from your image, then builds three smooth masks with smoothstep transitions at the band boundaries. The luminance_source dropdown matters more than you'd think:

  • lab_l (default) - the perceptual L channel, matching Photoshop's default. ~120 ms at 2K on CPU.
  • ycbcr_y - the fast path, ~7 ms at 1024 on CPU. Use it for realtime previews or CPU-bound work.
  • hsv_v - simple max-RGB, the least perceptual of the three.

The two bounds you'll actually set:

  • shadow_end - where the shadow band stops (default 0.33).
  • highlight_start - where highlights begin (default 0.67). Must be greater than shadow_end or the node raises.

soft_edge (default 0.1) controls the transition width: smaller means sharper band edges, larger means smoother blends.

Outputs are three MASKs: mask_shadows, mask_midtones, mask_highlights. A classic move: multiply a color LUT through mask_midtones only, and you get split-tone grading without touching shadows or highlights.

Install is the shared pack install - one clone covers every PixelPro node:

cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/ComfyUI-JH-PixelPro.git
cd ComfyUI-JH-PixelPro
pip install -r requirements.txt

Or ComfyUI Manager → search "ComfyUI-JH-PixelPro" → Install → restart. This node lives under ComfyUI-JH-PixelPro/color.

Troubleshooting: with very small soft_edge (< 0.03), the partition isn't exactly unity near band edges - you'll see a thin blend zone. The node rescales to keep it honest, so it's cosmetic, not a bug. On CPU, lab_l at 2K costs ~120 ms per call; if that's your environment, switch to ycbcr_y for interactive work. And it's RGB-only - feed it a 4-channel image and things get weird. None of the mask nodes in this pack need a model download, so this one is a light, immediate install.

CategoryComfyUI-JH-PixelPro/color

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
luminance_sourceCOMBOlab_lLuminance channel. 'lab_l' is perceptual (Photoshop default, ~120ms @ 2K CPU). 'ycbcr_y' is fast (~7ms @ 1024 CPU) — use for realtime preview. 'hsv_v' is simple max-RGB and less perceptual.
shadow_endFLOAT0.330–0.5Upper bound of the shadow band. Luminance values below this (minus half of soft_edge) count fully as shadow.
highlight_startFLOAT0.670.5–1Lower bound of the highlight band. Luminance values above this (plus half of soft_edge) count fully as highlight. Must be > shadow_end.
soft_edgeFLOAT0.100.01–0.3Smoothstep transition width at both band edges. Smaller = sharper bands, larger = smoother blend. Partition-of-unity preserved: shadows + midtones + highlights ≈ 1.

Outputs (3)

NameTypeDescription
mask_shadowsMASK
mask_midtonesMASK
mask_highlightsMASK