Dashed to Solid Line
Turning dashed lines solid so the line detector stops seeing twenty fragments
- image
- image
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 bygap_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.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| gap_size | INT | 151–100 | — |
| method | COMBO | 3 options: morphological, hough_lines, hybrid | |
| line_thickness | INT | 11–10 | — |
| threshold | INT | 1270–255 | — |
| invert_input | BOOLEAN | false | — |
| skeletonize_output | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |