Nodes/ComfyUI-Image-Analysis-Tools/Edge Density Analysis
ComfyUI Node

Edge Density Analysis

How much 'stuff' is actually in this image?

By ThatGlennD·Created about a year ago·Updated about a month ago· 23
Edge Density Analysis
  • image
  • edge_density_score
  • edge_density_map
  • interpretation
  • edge_preview
methodCanny
block_size32
visualize_edge_maptrue

Some images feel dense with detail - fabric texture, hair strands, brickwork - and others feel like a clean gradient with a subject dropped on top. Edge Density Analysis puts a number on that "visual energy": it runs an edge detector over the image, then measures what fraction of each block is actually edge pixels. High score = busy and detailed. Low score = smooth, minimal, possibly empty.

It's part of ThatGlennD's ComfyUI-Image-Analysis-Tools pack, and it's a slightly different question than the sharpness nodes ask. Sharpness asks are the edges crisp; edge density asks are there edges at all. A perfectly sharp photo of a white wall scores near zero on density. That's not a bug - it's the metric being honest about content, not focus.

How it works

You pick the edge detector with the method combo:

  • Canny (default): the multi-stage detector with thresholding and non-maximum suppression. Clean, well-defined edges, tolerant of minor noise. Good for "how much structure is really here."
  • Sobel: a straight gradient magnitude, normalized to 0–255. Captures soft transitions too, so it reads finer texture and subtle detail. Slower to interpret but more sensitive.

Either way the edges are measured per block (the block_size input, 8–128, default 32) as the fraction of nonzero pixels, and the mean across blocks becomes edge_density_score - a float from 0 to 1. The interpretation string translates it: "Very smooth (0.02)", "Soft detail (0.08)", "Moderate detail (0.26)", or "Dense detail (0.41)". Handy for a display node or a text filter.

Two image outputs:

  • edge_preview: the detected edges overlaid on the original - a 60/40 blend of image and edge map. Always produced, and the most useful single output for debugging. If the preview shows edges all over your subject, your high score means what you think.
  • edge_density_map: the per-block heatmap in magma (bright = dense edges), only when visualize_edge_map is on.

Where it's useful

  • Flagging detail-poor renders - the "did the sampler just give up and smooth everything" check, before you burn an upscale pass on a frame with no structure to upscale.
  • Comparing styles: same prompt, different models or LoRAs, and you want the one that kept the texture.
  • Building filters to select for realism (dense) or minimalism (sparse).

The trap: edge density can't tell texture from noise. Grain and artifacts are also edges, and a noisy image will score "dense" while looking bad. Cross-check with Noise Estimation from the same pack when a high density score surprises you.

Install

Manager (search "Image Analysis") or:

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

Restart ComfyUI. Requirements: numpy, opencv-python, matplotlib, scikit-learn, Pillow, torch. No models, no VRAM, CPU-fast.

Common gotchas

  • Pack won't load: scikit-learn is imported at module load by the Color Harmony Analyzer - missing it disables the whole pack. Windows portable: python_embeded\python.exe -m pip install scikit-learn.
  • comfy_api import error: update ComfyUI; this pack uses the newer node API.
  • First frame only: batches score frame 0; video frames go through one at a time.
  • Black placeholder map: edge_density_map is a real heatmap only when visualize_edge_map is on; otherwise it's a placeholder. edge_preview is always real, so lean on that.

block_size is the knob worth touching: small blocks (16) find detail concentrated in small areas like faces or fabric; large blocks (64+) smooth over local texture and report the macro structure.

CategoryImage Analysis

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
methodCOMBOCanny2 options: Canny, Sobel
block_sizeINT328–128
visualize_edge_mapBOOLEANtrue

Outputs (4)

NameTypeDescription
edge_density_scoreFLOAT
edge_density_mapIMAGE
interpretationSTRING
edge_previewIMAGE