ComfyUI Node

Multi-Scale Retinex

Fix bad lighting without touching a single weight file

By EricRollei·Created 9 months ago·Updated 8 months ago· 9
Multi-Scale Retinex
  • image
  • enhanced_image
  • processing_info
presetbalanced
color_restorationtrue
gain1.0
offset0
small_scale15
medium_scale80
large_scale250

If half the nodes in this pack come with an asterisk about missing weights or on-the-fly training, this one's the relief: it's pure classical image processing, math you can trace by hand, and it works the moment you install it. No model, no download, no GPU requirement. If your image has uneven lighting, washed-out shadows, or looks flat because the illumination is fighting the actual content, this is the node built for exactly that job.

The idea behind Retinex

Retinex theory treats an image as illumination multiplied by reflectance - what the light is doing, times what the surface actually looks like - and tries to strip out the illumination part so the underlying reflectance (the "true" color and detail) comes through. Multi-Scale Retinex does this by comparing the image to several blurred versions of itself at different scales (small, medium, large Gaussian radii), which approximates the illumination at each scale, and combining the results. The small scale recovers fine local contrast, the large scale corrects broad, slow-varying lighting like a shadow gradient across a whole scene. MSRCR - the color-restoring variant this node defaults to using - adds a correction step so colors don't shift toward gray as a side effect, which is the classic failure mode of plain Retinex on saturated images.

Inputs and outputs that matter

  • preset - the one dial that actually matters for most people. balanced is the sane default for general images. fine_detail weights the small scale more heavily, useful when local contrast (skin texture, fabric weave) matters more than global lighting. global_illumination weights the large scale, for correcting broad lighting problems like a backlit subject or an unevenly lit room. custom unlocks manual control over all three scales if you know exactly what radius you want.
  • color_restoration (boolean, default on) - keep this on unless you specifically want the older, desaturating MSR behavior; MSRCR (restoration on) is what most people actually want.
  • gain and offset - post-processing brightness/contrast trim after Retinex does its work. Leave at defaults first, adjust only if the result is too dark or too flat.

Outputs: enhanced_image and processing_info, a string reporting which scales were used (both the base preset values and any resolution-adapted values) and your gain/offset settings.

Installing it

Through ComfyUI Manager, search Eric's Image Processing Nodes. By hand:

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

Restart ComfyUI. Nothing else to configure - this is one of the few nodes in the pack with zero model-weight dependency, so if you're troubleshooting a broken install and want to confirm the pack itself loaded correctly, this is a good node to test first since there's no separate failure mode to rule out.

Where people get burned

The one real trap is reaching for the custom preset before trying the built-in presets, and then fighting three interacting scale sliders to reproduce what fine_detail or global_illumination already does out of the box. Start with the presets; only drop into custom once you've confirmed none of them get you close, since the three scales genuinely do interact (a large small_scale value starts overlapping with what medium_scale is supposed to be doing, and the boundaries blur).

The other thing worth knowing: Retinex enhancement can look genuinely aggressive on images that didn't actually have a lighting problem - it'll still find some illumination variation to correct and can introduce a mild halo around high-contrast edges as a result. If you're running this as a blanket preprocessing step rather than a targeted fix, keep gain conservative and check a few frames before committing it to a whole batch.

CategoryEric's Nodes/Advanced Enhancement

Inputs (8)

NameTypeDefaultDescription
imageIMAGE
presetCOMBObalancedRetinex processing preset: • balanced: Good for most images • fine_detail: Emphasizes local details • global_illumination: Corrects overall lighting • custom: Use manual scale settings
color_restorationoptBOOLEANtrueApply color restoration (MSRCR): • True: Preserve natural colors • False: Standard MSR without color correction
gainoptFLOAT1.00.1–3Output gain factor: • 0.5: Subtle enhancement • 1.0: Standard enhancement • 2.0: Strong enhancement
offsetoptFLOAT0-50–50Output offset: • -20: Darken result • 0: No offset • +20: Brighten result
small_scaleoptFLOAT155–50Small scale (fine details) - only used with 'custom' preset
medium_scaleoptFLOAT8020–200Medium scale (local contrast) - only used with 'custom' preset
large_scaleoptFLOAT250100–500Large scale (global illumination) - only used with 'custom' preset

Outputs (2)

NameTypeDescription
enhanced_imageIMAGE
processing_infoSTRING