Nodes/ComfyUI-ArchiGraph/Hough Lines πŸ¦β€πŸ”₯
ComfyUI Node

Hough Lines πŸ¦β€πŸ”₯

The math version of line detection β€” rho and theta, not endpoints

By vincentfsΒ·Created 2 years agoΒ·Updated 9 months agoΒ· 3
Hough Lines πŸ¦β€πŸ”₯
  • nparrays
  • lines
β—„rho_res1.0β–Ί
β—„theta_res1.00β–Ί
β—„threshold100β–Ί

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.

CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ“€ OpenCV

Inputs (4)

NameTypeDefaultDescription
nparraysNPARRAY8-bit, single-channel binary source image.
rho_resFLOAT1.00.5–2Distance resolution of the accumulator in pixels.
theta_resFLOAT1.000.05–2Angle resolution of the accumulator in degrees.
thresholdINT100Accumulator threshold parameter. Only those lines are returned that get enough votes (> threshold).

Outputs (1)

NameTypeDescription
linesLIST_LINEβ€”