Hough Lines π¦βπ₯
The math version of line detection β rho and theta, not endpoints
- nparrays
- lines
The standard Hough Transform is the classic answer to "are there straight lines in this image, and what are they?" It votes every edge pixel into an accumulator and extracts the lines that got the most votes. This node wraps OpenCV's HoughLines and returns each detected line as a (rho, theta) pair - the polar coordinates of the line's perpendicular. It's the mathematical line detector, and that's both its power and its annoyance.
Why rho and theta instead of endpoints
A line in polar form is fully described by rho (distance from the origin to the line along its normal) and theta (that normal's angle). Infinite lines don't have endpoints, so this representation is exact - great for fitting vanishing points, computing intersections, or analyzing perspective geometry, where you genuinely want the line's equation rather than a drawn segment. If instead you want to draw the lines on an image, the pack's other node - Hough Lines Probabilistic - returns actual (x1, y1, x2, y2) segments and is the one to reach for. This node is the one to reach for when you're doing math.
The inputs
nparrays: an 8-bit, single-channel binary image (the tooltip says so) - so Canny or threshold first.rho_res(default 1): distance resolution of the accumulator in pixels. Finer = more sensitive, more compute.theta_res(default 1): angle resolution in degrees; the node converts to radians for OpenCV.threshold(default 100): minimum accumulator votes. The one you'll tune - lower catches more (and noisier) lines, higher keeps only confident ones.
Output
lines - a LIST_LINE: per image in the batch, a list of (rho, theta) pairs. No lines found gives you an empty list rather than an error.
Install
ComfyUI Manager β search ComfyUI-ArchiGraph, or:
cd ComfyUI/custom_nodes
git clone https://github.com/vincentfs/ComfyUI-ArchiGraph
Restart and run the pack's install script once for the OpenCV dependency. No models involved.
Gotchas
- Don't grab this node expecting drawable segments. You'll get rho/theta and then have to compute endpoints yourself - which is exactly why the probabilistic sibling exists.
- Binary input only. Feed it a photo and you'll get a pile of spurious "lines."
- Theta here is in degrees on the UI, but you'll consume the output as radians if you do any math with it downstream - keep that conversion in mind.
For perspective math and vanishing-point work, this is the right tool and it's precise about it. For drawing lines on an image, you want its sibling. Knowing which is which is half the battle.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| nparrays | NPARRAY | 8-bit, single-channel binary source image. | |
| rho_res | FLOAT | 1.00.5β2 | Distance resolution of the accumulator in pixels. |
| theta_res | FLOAT | 1.000.05β2 | Angle resolution of the accumulator in degrees. |
| threshold | INT | 100 | Accumulator threshold parameter. Only those lines are returned that get enough votes (> threshold). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| lines | LIST_LINE | β |