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

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

Find the straight lines in your edge map, endpoints included

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

If you're doing anything structural - floor plans, facade detection, perspective grids, shelf-detect-for-photography - you eventually need to answer "where are the straight lines in this image?" That's the Hough Transform's job, and the probabilistic variant is the one you usually want, because it returns actual line segments with start and end points instead of infinite lines described in polar coordinates.

The "probabilistic" part isn't a marketing flourish. Standard Hough (cv2.HoughLines) votes every edge pixel into an accumulator and hands back rho/theta pairs you then have to clip to the image yourself. The probabilistic version (HoughLinesP) takes random edge-point samples, finds the lines, and then walks the edges to compute real (x1, y1, x2, y2) segments. That's a massive convenience for drawing or measuring.

The inputs that actually matter

It takes an NPARRAY - and per the tooltip, it should be an 8-bit, single-channel binary source image. So the pipeline is: image β†’ To Nparray β†’ (blur) β†’ Canny β†’ Hough. Feed it a raw color photo and it'll technically run (it converts to gray internally), but you'll get noise. Edges first.

  • rho_res (default 1): distance resolution of the accumulator, in pixels. Smaller = finer detection, more computation.
  • theta_res (default 1): angle resolution in degrees (the node converts to radians for you).
  • threshold (default 100): minimum accumulator votes a line needs. This is the one you'll tune most - lower it and you get more, noisier lines; raise it for only the confident, long ones.

Output

lines is a LIST_LINE - a list, per image in your batch, of (x1, y1, x2, y2) segments. This pack's other nodes eat that format, and you can draw segments back onto the image with the drawing nodes. If no lines are found, you get an empty list rather than an error, which is polite but also means "your threshold is too high" more often than "there are no lines."

A realistic workflow

Architectural detail: photo β†’ To Nparray β†’ Canny β†’ Hough Lines Probabilistic β†’ Draw (lines back onto the image) β†’ To Image β†’ save. You get the detected geometry overlaid on the original in one pass. Want only the strongest lines? Crank the threshold to 150+ and see what survives.

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 - OpenCV is the real dependency here, and there are no models to fetch.

Gotchas

  • It wants binary input. Canny or threshold first, always.
  • This is the probabilistic node - the pack also ships a plain "Hough Lines" that outputs rho/theta. If you need endpoints for drawing, you're on the right page; if you need line equations for math, the other one is the fit.
  • CPU-bound, like everything in this pack's OpenCV section. Fine for one image, slow if you batch hundreds.

For "give me the lines, actually drawable," this is the node. That's its entire job and it does it cleanly.

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β€”