Nodes/ComfyUI-HappNodeSet/Contour Gap Closer
ComfyUI Node

Contour Gap Closer

Detects broken contour lines and joins nearby endpoints to produce closed, continuous paths.

By mikemojen·Created 8 months ago·Updated 3 months ago· 0
Contour Gap Closer
  • image
  • image
  • contour_mask
max_gap20
threshold0.50
inverttrue
morph_close_radius2
re_skeletonizefalse
direction_weight0.30
iterations3
output_mode
dilation_radius1
Categoryimage/contour

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
max_gapINT201–200Maximum pixel distance between endpoints to bridge
thresholdFLOAT0.500.01–0.99Binarization threshold (0-1)
invertBOOLEANtrueTrue = dark lines on light background
morph_close_radiusINT20–20Morphological closing radius to heal micro-gaps first (0=skip)
re_skeletonizeBOOLEANfalseSkeletonize the output to single-pixel lines
direction_weightFLOAT0.300–1Direction matching strictness (0=any, 1=strict collinear)
iterationsINT31–10Repeat endpoint-detection + connection N times
output_modeCOMBO3 options: original_thickness, skeleton, dilated
dilation_radiusINT11–10Line thickness when output_mode='dilated'

Outputs (2)

NameTypeDescription
imageIMAGE
contour_maskMASK