Focus Peaking
See which edges are actually sharp
- image
- passthrough
- focus_peak
Focus peaking is the camera-assist feature that paints a colour over the parts of the frame that are in sharpest focus. It exists because your eye cannot reliably tell you whether a face is focused at 100% zoom, and it absolutely cannot tell you at fit-to-window. So the tool measures edge strength for you and draws on the answer.
How it works
It converts to BT.709 luma, runs a Sobel edge detector, and normalises the result to the strongest edge in each frame. Pixels above your threshold get painted, with the paint blended over the original by strength.
That normalisation is the thing to understand, because it's both the feature and the limitation. Per-frame normalisation means the node adapts to each image - a dark, low-contrast frame still gets usable peaking instead of nothing. It also means the threshold is a relative measure. 0.2 on one frame and 0.2 on the next are not comparable numbers, so don't use the peaking density as an objective sharpness metric across a sequence. It's an aid, not a QC measurement.
Two outputs: passthrough (the untouched image) and focus_peak (the overlay). Preview the second, pass the first onward.
The controls
threshold (default 0.2) is sensitivity. The node's own docstring is helpful here: 0.15–0.25 for most footage, 0.05–0.10 if you want to catch micro-focus variation, 0.40+ for hard edges only - fast lens, close subject. Start at the default and move it to match the shot.
peak_color offers Red, Green, White, Yellow and Cyan. Green is the camera-assist classic; white is what you use when the scene is full of saturated reds and greens and the overlay disappears.
strength (0.85) blends the overlay. At 1.0 the peaking is fully opaque, which is great for debugging and unpleasant to look at.
What it's actually good for in ComfyUI
You're not shooting on a cinema camera here, so the use case shifts. Three real ones:
Checking an upscale or a detail pass. Did your sharpen actually add edge definition, or did it add noise? Overlay the peaking on a before and an after and the difference is immediate, because the Sobel magnitude responds to exactly what a sharpness claim is about.
Catching over-processing. A pass that's been denoised, sharpened and squeezed comes back with peaking decorating every strand of hair and every texture fiber. That's the tell for a plastic, over-cooked result - the edges are uniformly strong because everything has been pulled to the same level.
Judging a depth-of-field render. If your defocus is meant to fall off behind the subject, the peaking should be a tight band on the subject and absent behind it. When it's everywhere, the blur is a uniform smear, and you can see it in one glance instead of guessing.
Install
Ships in Radiance. Manager → search Radiance → install, restart ComfyUI, hard-refresh the browser. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/fxtd-studios/radiance.git
cd radiance
python -m pip install -r requirements.txt
Windows portable users: python_embeded\python.exe on that pip line. The Sobel work is NumPy, already in the requirements. No models.
Where people get burned
Treating peaking as focus. It's edge strength. A busy, high-frequency texture in the out-of-focus background can light up as readily as the subject's eye. Read it as "where is there contrast at the pixel level", not "what is in focus".
Peaking on a linearly-encoded image. The overlay is display-oriented; if you feed scene-linear float, contrast is distributed differently and the threshold you tuned on a display image won't behave the same. Peak a display encode.
Comparing frames. Because the normalisation is per-frame, a frame with a single strong edge will have everything else pushed below threshold, while a uniformly-detailed frame lights up all over. If you need a sequence comparison, do it in a montage, not by eye across frames.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Image to check, returned unchanged on passthrough. Edges are measured on BT.709 luma, normalised to the strongest edge in each frame. | |
| threshold | FLOAT | 0.200.01–1 | Normalised Sobel magnitude above which a pixel is considered in-focus. |
| peak_color | COMBO | Red | Overlay colour painted on pixels above threshold. |
| strength | FLOAT | 0.850–1 | Blend factor for the peaking overlay. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| passthrough | IMAGE | — |
| focus_peak | IMAGE | — |