Nodes/Duanyll Nodepack/Laplacian Variance
ComfyUI Node

Laplacian Variance

The classic sharpness/blur detector, one number out

By Duanyll·Created about a year ago·Updated 4 months ago· 2
Laplacian Variance
  • image
  • laplacian_variance

Laplacian Variance is the old reliable of blur detection - the "is this image actually sharp?" test that predates every neural sharpness estimator and still gets the job done. Feed it one image and it returns a single FLOAT. Higher means sharper. A crisp photo or render scores in the hundreds; a soft, out-of-focus, or upscaled-to-soup image scores low. It's not calibrated to any absolute "sharp" threshold - that depends on your content - but it's rock-solid for relative comparisons and for catching the obviously-blurry image.

How it works

The mechanism is classic OpenCV, and it's the whole trick: the image is converted to 8-bit grayscale, run through a Laplacian filter (a second-derivative edge detector, computed at 64-bit precision so it doesn't lose the negative values), and then the variance of the result is taken. The logic is that a sharp image has strong, varied edges - high variance - while a blurry image has weak, uniform ones. The node processes the first image in the batch, so a single image in, one number out.

Inputs and outputs

  • image (required) - the IMAGE to test.

Output: laplacian_variance, a FLOAT. The value is also printed to the console and shown on the node, so you can read it without wiring anything.

Where you'd actually use it

  • Quality gating in a batch: generate a pass, run Laplacian Variance, and branch on "is this above the threshold" to auto-drop blurred generations. This is the classic use and it works.
  • A/B sanity checks: comparing two upscalers or two denoise settings - whichever output scores higher is, on average, the sharper one.
  • Focus-assist style workflows: checking whether an input photo is sharp enough to bother upscaling in the first place.

The honest caveat: it measures edge variance, not "quality." A busy, noisy image can score high while an actually-pleasant smooth image scores lower. Use it to catch the obvious failures, not to rank good images against each other.

Installing it

It's part of Duanyll Nodepack. ComfyUI Manager → search "Duanyll Nodepack" → install → restart, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack

This one needs OpenCV, and unlike the SSIM nodes, opencv-python-headless is in the pack's requirements - so Manager installs it for you and it just works. The node sits under duanyll/metric.

Categoryduanyll/metric

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
laplacian_varianceFLOAT