ComfyUI Node

Clipping Analysis

Where did the highlight detail go? This node finds it

By ThatGlennD·Created about a year ago·Updated about a month ago· 23
Clipping Analysis
  • image
  • clipping_score
  • clipping_map
  • interpretation
modeHighlight/Shadow Clipping
threshold5
visualize_clipping_maptrue

Clipping is what photographers mean when they say the highlights are "blown" or the shadows are "crushed": pixels shoved so hard against pure white or pure black that the gradation inside them is gone. Diffusion models do this constantly - a too-hot prompt for bright skies, a contrast curve pushed too far, an over-saturated palette - and you can't always see it on a small preview. Clipping Analysis counts the damaged pixels for you and paints them on a map.

It's one of the twelve diagnostic nodes in ThatGlennD's ComfyUI-Image-Analysis-Tools. Pure CPU math, no model downloads, runs in milliseconds. It's the tonal-damage detector in the pack, and it pairs naturally with ContrastAnalysis and the RGBHistogramRenderer - the histogram shows you the clipped edges of the curve, this node shows you where they sit in the frame.

How it works

You pick one of two detection modes, and the node does the rest:

  • Highlight/Shadow Clipping (default): converts to grayscale, then flags every pixel <= threshold as a crushed shadow and every pixel >= 255 - threshold as a blown highlight. The map renders shadows blue and highlights red.
  • Saturation Clipping: converts to HSV and flags pixels where both saturation and brightness are within threshold of the max - the oversaturated-burn look. Clipped zones show up magenta.

The threshold input (1–50, default 5) is how close to the edge counts as clipped. Lower = strict, only truly destroyed pixels. Higher = lenient, catches near-clipping. Default 5 is a sane place to start; if you're doing print-safety checks you'll probably want it lower.

Outputs

clipping_score is the fraction of the image that clipped, 0–1 (so 0.0033 is 0.33% - a tiny patch). interpretation gives you the same number as a sentence like "Clipped highlights/shadows: 0.33%", ready for a Text Display or a filter. clipping_map is the color-coded mask. All three come out of every run; the map is a real IMAGE tensor you can preview or feed downstream.

The honest caveat: a little clipping is normal and often intentional - a specular highlight that clips to pure white is what makes things look glossy. This node is useful when clipping is unintended or extensive: crushed blacks from heavy CFG, blown skies, or color burnout from an over-tuned LoRA. Set up a filter on the score and it becomes a cheap reject gate for a render pipeline.

Install

Same as every node in this pack - ComfyUI Manager (search "Image Analysis"), or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ThatGlennD/ComfyUI-Image-Analysis-Tools
cd ComfyUI-Image-Analysis-Tools
pip install -r requirements.txt

Then restart ComfyUI. Requirements are numpy, opencv-python, matplotlib, scikit-learn, Pillow and torch - for most people everything except possibly matplotlib/scikit-learn is already sitting in the ComfyUI venv. No models to download.

Common gotchas

  • No nodes after install? The pack imports every module at startup and the Color Harmony Analyzer imports scikit-learn at module level, so a missing scikit-learn sinks the entire pack. In the Windows portable build: python_embeded\python.exe -m pip install scikit-learn.
  • Import error mentioning comfy_api? The pack targets ComfyUI's newer node API; a very old ComfyUI needs updating first.
  • First frame only: like all twelve nodes here, only frame 0 of a batch is analyzed. Feed video frames individually.

The trap to avoid: don't run this on an image that's already been through a color-grade or a tone curve you intend to keep - you'll be flagging your own aesthetic choices. Run it on raw outputs, when you're deciding whether a render is safe to push further.

CategoryImage Analysis

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
modeCOMBOHighlight/Shadow Clipping2 options: Highlight/Shadow Clipping, Saturation Clipping
thresholdINT51–50
visualize_clipping_mapBOOLEANtrue

Outputs (3)

NameTypeDescription
clipping_scoreFLOAT
clipping_mapIMAGE
interpretationSTRING