Nodes/ComfyUI-HappNodeSet/Dashed to Solid Line
ComfyUI Node

Dashed to Solid Line

Turning dashed lines solid so the line detector stops seeing twenty fragments

By mikemojen·Created 8 months ago·Updated 3 months ago· 0
Dashed to Solid Line
  • image
  • image
gap_size15
method
line_thickness1
threshold127
invert_inputfalse
skeletonize_outputtrue

Dashed lines are the enemy of every line detector. A single dashed stroke is twenty separate segments to a skeletonizer, each one ending in a junction, each one a candidate "line" in its own right. Dashed to Solid Line exists to close those gaps before the measurement nodes see them. It's a preprocessing node with a single job: take an image of dashed lines and output the same lines as continuous strokes. If you're working with CAD exports, dimension lines, or hidden-line drawings, this is the node you didn't know you needed until your line count came back at 47 when it should have been 4.

How it works

It binarizes at threshold (default 127), then bridges the dashes. The method dropdown picks the strategy:

  • morphological - runs directional morphological closing with horizontal, vertical, and both diagonal kernels sized by gap_size. It's the "connect what's clearly meant to connect" approach, and it's excellent for clean, mostly-horizontal/vertical drawings.
  • hough_lines - uses OpenCV's probabilistic Hough transform to find line segments and redraw them as continuous straight lines. Handles arbitrary angles natively and straightens as it goes.
  • hybrid (default) - morphological pass first, Hough pass second, combined. Best results on real-world messy input, slightly more processing time. This is the one to leave it on.

gap_size (default 15) is the maximum dash gap in pixels to bridge - the single most important setting. Too small and long gaps stay open; too large and you'll start fusing separate parallel lines together. line_thickness (1–10, default 1) sets the redrawn stroke width, and skeletonize_output (default on) thins the result back to 1-pixel-wide lines afterward, which is what the downstream detectors want. invert_input flips the polarity for white-on-dark sources.

What comes out

A single image output: the same diagram, dashed lines now solid, ready to feed LineDetector or LineLengthCalculator.

Where it fits

The standard chain is Load Image → Extract Black → DashedToSolidLine → LineDetector. For a dimensioned drawing that's the difference between a sensible line count and a chaotic one. It also cleans up nicely before RasterToUniformSVG if you're converting to vector and don't want fifty separate dash segments in the SVG path data.

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. Pack-standard deps: numpy, opencv-python (the Hough and morphology work lives there), scipy, scikit-image, Pillow, torch, svgwrite.

Common issues

gap_size is where people get burned. Crank it up to handle wide dashes and suddenly parallel lines at close spacing fuse into blobs - the morphological kernels don't know the difference between "gap in a dashed line" and "space between two real lines." If that happens, drop gap_size and switch to hough_lines, which is smarter about preserving parallelism. Also, dithering or JPEG artifacts between dashes can produce tiny specks that Hough tries to connect; running it after a light Extract Black pass fixes most of that. And as always: preview before measuring, because this node changes topology - a wrong setting here propagates straight into every downstream count.

Categoryimage/processing

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
gap_sizeINT151–100
methodCOMBO3 options: morphological, hough_lines, hybrid
line_thicknessINT11–10
thresholdINT1270–255
invert_inputBOOLEANfalse
skeletonize_outputBOOLEANtrue

Outputs (1)

NameTypeDescription
imageIMAGE