Classical Vision · Retina

What is the Classic Hough Transform?

The Classic Circle Hough Transform solves the problem of finding circular shapes from incomplete or noisy edges by using a deterministic voting algorithm. Learn how the algorithm works, the mathematics behind circle voting, and how to use it in the Telekinesis Agentic OS.

Imagine a robot checking whether a drilled hole is in the correct place. The robot does not need to understand the whole object; it only needs to find a circle and measure it. The Classic Hough Transform can do this from image geometry without training a model on labeled examples.

1. What is the Classic Hough Transform?

Suppose a robot inspects a metal plate and must verify that a drilled hole is present, round, and in the correct place. Training a semantic detector for “hole” may be unnecessary. The drawing already tells us the feature should be circular, so the image-processing method can search directly for that geometry.

The Circle Hough Transform is a voting method for finding circular structures in an image. It does not learn the appearance of a bearing, cap, or pipe. Instead, it gathers evidence from boundary pixels and asks whether many of them agree on one centre and radius.

This makes the method attractive in controlled workcells. It needs no labeled training set, and its parameters can often be connected to physical knowledge. If calibration says the hole should appear between 35 and 45 pixels in radius, the algorithm can ignore every other size.

The same assumption also defines the limit. If perspective turns the circle into an ellipse, most of the boundary is hidden, or nearby texture creates many circular arcs, the evidence no longer gathers cleanly around one circle.

1.1 The Complete Path From Image Edges to a Circle

Edge evidence → circle parameters

Edge pixelsExtracted before Hough voting
Radius rangeAllowed circle sizes
Circle parameterizationRepresent each circle by centre and radius
Vote generationEach edge supports possible (a, b, r)
Parameter accumulatorAdd evidence in three dimensions
Peak selectionKeep strong, separated hypotheses
CirclesCentres and radii

Many edge pixels agreeing on the same parameters create a detectable accumulator peak.

The Circle Hough Transform itself starts from edge evidence and votes in centre–radius parameter space. Canny is one possible upstream edge detector, not a layer of the Hough transform. Adapted as an explanatory diagram fromYuen et al., circle Hough methods.

The pipeline begins with an edge image rather than raw camera brightness. An upstream detector such as Canny has already marked pixels where intensity changes sharply. Some marks belong to the circle we want; others come from scratches, shadows, or nearby objects.

Now take one marked pixel. Many different circles could pass through it, so that pixel cannot determine a circle by itself. The Hough transform lets it vote for all center-and-radius combinations that would make the pixel lie on a circle. Every other edge pixel casts its own votes.

Those votes are collected in an accumulator—essentially a table indexed by possible horizontal center, vertical center, and radius. Random edges tend to spread their support across many possibilities. Pixels lying on the same real circle repeatedly vote for the same parameters, creating a peak in the table.

The final stage finds strong peaks and converts them back into circles in the image. Nothing is learned from a dataset: the engineer supplies the edge preprocessing, radius range, voting resolution, and acceptance threshold. The deeper sections explain how one edge pixel becomes a family of circle hypotheses.

1.2 An Edge Pixel Proposes Possible Circles

An edge pixel is an image location where brightness changes sharply enough that an upstream edge detector marks it as a possible boundary. Some edge pixels belong to the drilled hole; others may come from scratches, shadows, or nearby parts. At this stage, the Hough transform does not know which are useful.

To reason about circles, the algorithm uses three parameters: horizontal centre aa, vertical centre bb, and radius rr. The set of all possible triples (a,b,r)(a,b,r) is called parameter space. A single point in that space represents one complete circle hypothesis.

A circle with centre (a,b)(a,b) and radius rr contains image points (x,y)(x,y) satisfying

(x−a)2+(y−b)2=r2.(x-a)^2 + (y-b)^2 = r^2.

Here, (x,y)(x,y) is an image point on the circumference, (a,b)(a,b) is the candidate circle centre, and rr is its radius, all measured in image coordinates.

Take one edge pixel (x,y)(x,y). By itself, it does not define a circle. Many circles with different centres and radii could pass through that point. During Circle voting, the pixel votes for parameter combinations compatible with the circle equation. Those votes are stored in the Accumulator.

An accumulator is simply a grid of counters laid out over parameter space. When an edge pixel supports one candidate triple (a,b,r)(a,b,r), the algorithm increments that triple’s counter. At this point, one vote proves very little. The useful signal appears only when votes from many different edge pixels meet.

Now consider all pixels around the real hole. Each one votes for many possibilities, but the correct parameter triple (a,b,r)(a,b,r) is compatible with all of them. Their votes therefore pile up near the same accumulator cell. Peak decoding finds these strong peaks and converts them into the final Circles.

A direct implementation uses a three-dimensional accumulator—two dimensions for the centre and one for radius. That can require substantial memory and computation. Physical constraints immediately help: a known radius range removes implausible circles, and a crop removes irrelevant image regions.

The local edge gradient can narrow the search further. At a clean circle boundary, the gradient points approximately toward or away from the centre. Instead of voting in every direction, a boundary pixel can vote mainly along that line. Image downsampling and staged searches provide other ways to exchange precision for speed.

1.3 Agreement Between Many Pixels Creates a Peak

The key insight is the change of space. In the original image, the hole may appear as broken edge fragments separated by glare or noise. Connecting those fragments directly is difficult. In parameter space, every genuine fragment can still vote for approximately the same centre and radius. The corresponding accumulator cell becomes larger than its neighbours; this local maximum is called a peak.

Peak selection converts the strongest, sufficiently separated accumulator peaks back into image-space circles. A threshold controls how much supporting evidence is required. The output is therefore not a semantic claim that the region is a bearing or bore. It is a geometric claim that many edge pixels agree with one circle model.

Duda and Hart developed this parameter-space formulation for lines and analytic curves. Yuen et al. later compared five circle-finding approaches, including the standard transform, a hierarchical method, a two-stage method, and space-saving variants. These methods preserve the voting idea while reducing computation or accumulator storage in different ways.

Interactive Hough voting

Change the radius and watch edge agreement form a peak

—

Each edge supports possible circle parameters. When the tested radius matches the observed rim, many points agree on one center and the accumulator peak becomes strong.

Real implementations search many centers and radii; this slice fixes the center so the role of radius is visible.

The full circle equation gives every edge pixel too many possibilities. If radius is unknown, one pixel can vote for centres in every direction at every allowed radius. The gradient computed during edge detection provides an important shortcut.

For an ideal bright disk on a dark background, intensity changes most strongly in the direction normal to the boundary. A circle’s normal passes through its centre. If the normalized gradient direction at edge point (x,y)(x,y) is (gx,gy)(g_x,g_y), candidate centres for radius rr lie approximately at

(a,b)=(x,y)±r(gx,gy).(a,b)=(x,y)\pm r(g_x,g_y).

Here, (gx,gy)(g_x,g_y) is the normalized image-gradient direction at edge pixel (x,y)(x,y); rr is a candidate radius; and the plus/minus sign covers the two possible directions along the boundary normal.

Instead of drawing an entire candidate circle in centre space, the edge point votes along one or two normal directions. This dramatically reduces work. It also explains why noisy gradients are damaging: if blur, texture, or glare rotates the estimated normal, votes that should meet at one centre spread across neighbouring cells.

Smoothing before edge detection is therefore part of the geometry. Too little smoothing preserves noisy gradients; too much shifts or removes the true boundary. Kernel size should be chosen relative to the apparent edge width and smallest circle, not as an arbitrary default.

1.5 Understand the Main Parameters as Physical Choices

Circle-Hough parameters are easiest to tune when translated into scene meaning:

  • Minimum and maximum radius encode which physical circles are possible at the current camera scale.
  • Minimum centre distance expresses how close two real circles may appear. Setting it too high merges neighbouring holes; too low permits repeated detections.
  • Edge thresholds decide which intensity transitions may vote. Weak thresholds admit scratches and texture; strong thresholds can erase low-contrast arcs.
  • Accumulator threshold controls how much geometric agreement is required. Lower values recover partial circles but also accept accidental arcs.
  • Accumulator resolution exchanges speed and memory for precision. Coarse cells combine nearby hypotheses but quantize the result.

Tune them in that order of knowledge. Start with calibrated radius and workcell bounds, because rejecting impossible geometry is safer than compensating later with an aggressive vote threshold. Then adjust edge extraction on representative materials and lighting. Finally set peak acceptance using positive and negative inspection images.

1.6 Validate the Winning Circle Against the Pixels

An accumulator peak is a hypothesis, not a completed measurement. After obtaining (a,b,r)(a,b,r), sample edge support around the predicted circumference. For angle θ\theta, a point on the hypothesis is

x(θ)=a+rcos⁡θ,y(θ)=b+rsin⁡θ.x(\theta)=a+r\cos\theta, \qquad y(\theta)=b+r\sin\theta.

Here, θ\theta is the angle around the circle, (a,b)(a,b) is the detected centre, rr is the detected radius, and (x(θ),y(θ))(x(\theta),y(\theta)) is the corresponding circumference point.

Measure how much of the circumference lies near an observed edge, whether gradient directions point radially, and whether the intensity inside and outside matches the expected part. A circle supported by only one short shiny arc should score lower than one supported around most of its perimeter.

For dimensional inspection, refine the parameters with a least-squares circle fit to nearby edge points. Hough voting is robust for finding the basin of the solution; geometric fitting can then provide subpixel estimates and a residual. The residual is useful evidence: a low value supports a genuinely circular boundary, while a high value suggests an ellipse, damaged rim, or incorrect set of edge points.

1.7 Convert the Detection Into a Robot Measurement

Suppose the detected radius is 42 pixels and planar calibration gives 0.120.12 mm per pixel. The physical estimate is 5.045.04 mm. If the camera views the surface obliquely, however, one pixel does not have the same metric width everywhere and a physical circle projects as an ellipse. Rectify the plane before running the circle detector or use a model that accounts for the projective geometry.

The centre follows the same rule. A pixel centre is not a robot target until calibration maps it to a ray and depth or a known plane resolves the three-dimensional point. Record the image timestamp as well: a geometrically perfect centre from an old conveyor frame is still the wrong pick location.

1.8 When Should You Use the Hough Transform?

MethodPriorStrengthMain failure
Circle HoughCircular edge + radius rangeInterpretable; no trainingCluttered arcs and perspective ellipses
Contour + circle fitSegmented closed boundaryRich residual and shape diagnosticsNeeds clean, connected segmentation
Learned detectorLabeled appearance examplesHandles semantic variationData/domain dependence; coarse boxes
Segmentation modelPixel-level object conceptHandles irregular visible regionsMore compute and annotation complexity

The right method follows from the question. If a bore must be circular by specification, a detected centre, radius, and geometric residual are more informative than the semantic label “hole.” If the task is “find every coffee mug,” circle geometry is insufficient because mugs can appear from many viewpoints and are defined by more than a circular rim.

1.9 Why Circle Detection Fails

  • Concentric edges: a ring can create inner and outer detections; constrain radius or reason about paired radii.
  • Repeated detections: require greater separation between accepted centres or stronger accumulator evidence.
  • Missed partial circles: lower the accumulator threshold cautiously and constrain radius more tightly.
  • False texture circles: raise the edge threshold, denoise, crop, or mask irrelevant regions.
  • Elliptical projections: rectify the plane or use an ellipse-capable model.
  • Changing scale: update radius bounds using depth or maintain per-workcell parameters.

These failure modes follow directly from the voting mechanism. Extra arcs create competing peaks, weak edges produce too few votes, poor radius limits spread work across irrelevant parameter values, and perspective violates the circle model itself. The solution is often better scene constraints or a better geometric model—not merely a lower threshold.

2. How to Use the Classic Hough Transform in the Telekinesis Agentic OS

Telekinesis provides the Classic Hough Transform as the Retina Skill detect_circle_using_classic_hough. The code below loads a grayscale image, constrains the radius range, sets the edge and accumulator thresholds, and prints the returned circle centres and radii.

from telekinesis import datatypes, retina

image = datatypes.Image.from_url(
    url="https://assets.telekinesis.ai/examples/v1/images/metal_gears.jpg"
).to_grayscale()

circles = retina.detect_circle_using_classic_hough(
    image=image,
    inverse_resolution_ratio=1,
    min_distance=50,
    min_radius=40,
    max_radius=60,
    canny_detector_upper_threshold=300,
    accumulator_threshold=30,
)

for center, radius in zip(circles.centers, circles.radii):
    print(f"center={center}, radius={radius}")

The rendered result shows which accumulator peaks survived as circles. Look for repeated detections on concentric edges and false votes from arcs or gear teeth before using a centre as a robot target.

Circular structures detected by Retina

Strong, repeated circular edge evidence creates accumulator peaks. Texture inside a part is largely irrelevant unless it creates competing edges.

Try it out

Build with the Classic Hough Skill in Retina

See the complete Skill signature, circle parameters, output schema, and current examples.

Open Hough Circle docs

Runnable example

Run the classic Hough example

Open the exact Python script used to detect circles with the classic Hough transform and Retina.

View Python example

3. Benchmarking

3.1 Evidence Reported in the Circle-Hough Literature

The classic literature does not provide a modern, universal AP/latency leaderboard. Yuen et al. compare standard, fast, two-stage, and space-saving Hough variants on synthetic data and metallurgical images across four engineering dimensions:

Evaluation dimensionWhat the paper studies
AccuracyCentre and radius recovery
ReliabilityDetection stability under image variation
ComputationCost of accumulating and finding peaks
StorageMemory required by alternative accumulator schemes

For your deployment, report centre error and radius error in pixels and millimetres, precision/recall under an explicit matching tolerance, false circles on negative images, and p50/p95 end-to-end latency.

4. Where to Go Next?

5. References