Luminosity Masking
Select by Brightness, Not by Shape
- image
- mask_shadows
- mask_midtones
- mask_highlights
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 thanshadow_endor 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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| luminance_source | COMBO | lab_l | Luminance 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_end | FLOAT | 0.330–0.5 | Upper bound of the shadow band. Luminance values below this (minus half of soft_edge) count fully as shadow. |
| highlight_start | FLOAT | 0.670.5–1 | Lower bound of the highlight band. Luminance values above this (plus half of soft_edge) count fully as highlight. Must be > shadow_end. |
| soft_edge | FLOAT | 0.100.01–0.3 | Smoothstep transition width at both band edges. Smaller = sharper bands, larger = smoother blend. Partition-of-unity preserved: shadows + midtones + highlights ≈ 1. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask_shadows | MASK | — |
| mask_midtones | MASK | — |
| mask_highlights | MASK | — |