Nodes/ComfyUI-HappNodeSet/Contour Endpoint Visualizer
ComfyUI Node

Contour Endpoint Visualizer

A debug node that shows you the open ends before the gap closer goes to work

By mikemojen·Created 8 months ago·Updated 3 months ago· 0
Contour Endpoint Visualizer
  • image
  • debug_image
threshold0.50
inverttrue
morph_close_radius2
endpoint_radius5

This node is a diagnostic tool, and it knows it: its own description says "Shows detected contour endpoints as red circles for debugging." Contour Endpoint Visualizer takes an image, finds every open endpoint in the linework, and draws a red circle on each one. No measurement, no repair - just a map of where your contours are broken. It exists to answer one question before you run Contour Gap Closer: where are the breaks, and how far apart are they?

How it works

Same detection core as Contour Gap Closer: binarize at threshold (0–1, default 0.5) with invert defaulting to on (dark lines on light), optionally morphological-close with morph_close_radius (default 2) to first heal micro-gaps, skeletonize to 1px lines, then find pixels with exactly one skeleton neighbor. Those are the endpoints. Each gets a red circle of endpoint_radius (1–20, default 5) drawn on a copy of the original image.

The key thing to understand: because it uses the same morph_close_radius and binarization logic as the gap closer, the endpoints it shows you are the endpoints the closer will actually see. That consistency is the entire point - tune your threshold and closing radius here until the red circles match the breaks you can see with your eyes, then copy those settings over to Contour Gap Closer with confidence. This is the "measure twice, cut once" node.

The single output is debug_image (IMAGE).

Where it fits

The workflow is Extract Black → ContourEndpointVisualizer → (tune) → ContourGapCloser. Spend one pass here and you'll know the right max_gap for the closer without guessing, because you can literally see the distances. It's also useful purely as a QA check on a drawing - a pile of red circles on a supposedly clean diagram is your cue that the source needs cleanup (or that you're looking at dashed lines that need DashedToSolidLine first).

Install

Part of ComfyUI-HappNodeSet (mikemojen). ComfyUI Manager: search HappNodeSet. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/mikemojen/ComfyUI-HappNodeSet.git
pip install -r ComfyUI-HappNodeSet/requirements.txt

Restart ComfyUI. Uses scipy ndimage for neighbor counting and skimage for skeletonization - pack-standard deps, nothing extra.

Honest take

You will probably not use this node in a final production workflow - that's not what it's for. It's a setup tool, the way you calibrate a printer before a run. But the first time Contour Gap Closer bridges the wrong lines because you didn't check the endpoints, you'll wish you'd spent thirty seconds here first. It's the difference between repairing contours by measurement and repairing them by vibes.

Categoryimage/contour

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
thresholdFLOAT0.500.01–0.99
invertBOOLEANtrue
morph_close_radiusINT20–20
endpoint_radiusINT51–20Radius of the circles drawn at each endpoint

Outputs (1)

NameTypeDescription
debug_imageIMAGE