Nodes/ImgProcessing_ComfyUI/LightingPreprocessor
ComfyUI Node

LightingPreprocessor

Make a lighting map, not a prettier picture

By nirbhay-faaya·Created 2 years ago·Updated 2 years ago· 0
LightingPreprocessor
  • image
  • IMAGE

If you feed LightingPreprocessor an image expecting a nicer version of it, you'll be disappointed - and that's the wrong mental model anyway. What comes out is a low-res, aggressively blurred, blocky grayscale image, and that's the entire point. It's a lighting map: the picture stripped of texture and detail so only the light-and-shadow layout survives. That's exactly the kind of thing you feed into a shading-style ControlNet condition or a relighting workflow (the IC-Light family works off a similar "flat background" / lighting preference idea). You want the illumination, not the fabric weave.

The pipeline is hand-rolled and completely fixed: one input (image), one output (IMAGE), zero knobs. It converts to grayscale, scales the long edge up to 1536, boosts contrast, then runs a serious blur gauntlet - gaussian, box blur, median filter, more gaussian. Texture dies here. An unsharp mask brings the light/shadow boundaries back. Then CLAHE (adaptive histogram equalization, via OpenCV) evens the lighting across the frame. The telling step is the pixelate: downsize to a sixteenth, nearest-neighbor back up, so the map comes out as soft blocks. That's deliberate - it forces the result to carry only coarse lighting regions. A final blur, a contrast bump, a resize to roughly 512 on the long edge, and out it comes, the grayscale tripled into an RGB tensor. That mushy, blocky output is a feature; real lighting maps look like that.

Two things to know before you install.

First, this node is why the pack needs opencv-python. It's the only node here that imports cv2, but the import sits at the top of the pack's single Python file - so if cv2 is missing, the entire pack fails to load and all four nodes vanish from your menu, not just this one.

pip install opencv-python   # into your ComfyUI venv, then restart

Install is otherwise the pack-standard route: ComfyUI Manager → search "ImgProcessing_ComfyUI" → install → restart, or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/nirbhay-faaya/ImgProcessing_ComfyUI
# restart ComfyUI

No model files, no requirements.txt.

Second, two honest caveats about the node itself. It's CPU-only - the whole PIL/OpenCV filter chain runs on the CPU. Fine for stills, but every frame of video costs you the full pipeline. And there are no controls to speak of. If the map comes out too mushy or too sharp for your use, you can't tune it - the recipe is baked in. For "just give me a flat lighting map and I'll figure the rest out" it's perfect out of the box. For anything you need to dial in, you'd rather reach for a preprocessor with actual parameters.

It's also from a single-commit pack, untouched since May 2024. For pure image math with no weights and no API, that mostly means it doesn't rot. Feed it a photo, wire the output into a condition slot, and you get a workable light-and-shadow guide - which is more than its four-line README ever promised.

Categorysd

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE