Nodes/Nilor Nodes by Nilor Corp/๐Ÿ‘บ Blur Analysis
ComfyUI Node

๐Ÿ‘บ Blur Analysis

A blur heatmap node for batch QC, powered by a classic OpenCV trick

By nilor-corpยทCreated 2 years agoยทUpdated 6 months agoยท 6
๐Ÿ‘บ Blur Analysis
  • images
  • blur_analysis
โ—„block_size32โ–บ

If you generate images in batches - video frames, pose sweeps, seed runs - you've probably stared at 200 previews looking for the handful that came out soft or out of focus. Blur Analysis is a node that does that staring for you: it scores every region of every image for blurriness and returns a heatmap you can feed into a mask or just eyeball. It's a QC tool, not a filter - it doesn't fix anything, it tells you where the problem is.

How it works

The mechanism is a textbook computer-vision trick, and reading the source makes it obvious why the results are as good as they are. For each image in the batch:

  1. It converts to grayscale (using proper luminance weights, not a naive average).
  2. It applies a 3ร—3 Laplacian - a second-derivative edge detector. Sharp edges produce large values; a blurry image has weak edges.
  3. It takes the absolute value and averages it locally with a block_size ร— block_size window (default 32, range 1โ€“128), so you get a per-region edge-energy score rather than one number for the whole image.
  4. It normalizes and inverts: 1 - (edge response) means bright = blurry, dark = sharp. High values are your problem zones.
  5. It stacks the single-channel result to 3 channels so downstream nodes that index into RGB channels (the source explicitly mentions MaskFromRGBCMYBW-style nodes) work without surprises, and returns the whole batch as one tensor.

The output is a blur_analysis IMAGE in the same batch shape as the input. Smaller block_size = more local detail in the map (and noisier); larger = smoother, region-level verdicts. block_size is the one dial you'll actually touch, and it's a genuine tradeoff, not decoration.

What to do with it

The obvious move: threshold the heatmap (e.g. a simple level/contrast node, or threshold on the red channel since blur regions are bright) to build a mask of "blurry areas", then route that mask into inpainting or a sharper pass. The less obvious move, and the one this node is actually good at: batch QC. Run it on your whole frame set, glance at the maps, and you can spot the two out-of-focus frames in a 200-frame render in seconds instead of scrubbing thumbnails. Combined with a frame-trim node (this pack even ships a Wan frame-trimmer for exactly this video-batch context), it becomes a poor-man's sharpness gate.

One honest limitation: Laplacian variance is a crude sharpness proxy. A low-texture but perfectly sharp region (a clean sky) can score as "blurry" because there are no edges to detect. Don't read it as a quality score - read it as edge-energy, which is all it claims to be.

Install and dependencies

ComfyUI Manager (search "Nilor Nodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/nilor-corp/nilor-nodes
cd nilor-nodes && pip install -r requirements.txt

Restart ComfyUI; it lives under Nilor Nodes ๐Ÿ‘บ โ†’ Utilities. The real dependency is opencv-python (cv2) - present in the pack's requirements, but note this node converts tensors through CPU numpy, so very large batches will be memory-hungry. It expects a 4D tensor; if you feed it something else, it raises a descriptive error about the expected (batch, channels, height, width) layout, and it will auto-permute NHWC input if the channels look like they're last.

Bottom line

A well-grounded, honest little QC node - Laplacian blur detection done right, with a useful batched heatmap output instead of a single meaningless score. It's not going to blow your mind, but if you process batches at scale, it'll save you from looking at every frame. The batch dimension being preserved in the output is the feature most people miss and the reason to prefer it over hand-rolling the same math in a custom script.

CategoryNilor Nodes ๐Ÿ‘บ/Utilities

Inputs (2)

NameTypeDefaultDescription
imagesIMAGEโ€”
block_sizeINT321โ€“128โ€”

Outputs (1)

NameTypeDescription
blur_analysisIMAGEโ€”