Quality Magazine logo
search
cart
facebook twitter linkedin youtube
  • Sign In
  • Create Account
  • Sign Out
  • My Account
Quality Magazine logo
  • NEWS
  • PRODUCTS
    • FEATURED PRODUCTS
    • SUBMIT YOUR PRODUCT
  • CHANNELS
    • AUTOMATION
    • MANAGEMENT
    • MEASUREMENT
    • NDT
    • QUALITY 101
    • SOFTWARE
    • TEST & INSPECTION
    • VISION & SENSORS
  • MARKETS
    • AEROSPACE
    • AUTOMOTIVE
    • ENERGY
    • GREEN MANUFACTURING
    • MEDICAL
  • MEDIA
    • A WORD ON QUALITY PUZZLE
    • EBOOKS
    • PODCASTS
    • VIDEOS
    • WEBINARS
  • EVENTS
    • EVENT CALENDAR
    • IMTS
  • DIRECTORIES
    • BUYERS GUIDE >
      • Supplier Insights
    • NDT SOURCEBOOK
    • VISION & SENSORS
    • TAKE A TOUR
  • INFOCENTERS
    • Digital Quality Management Systems
    • NEXT GENERATION SPC & QUALITY ANALYTICS
  • AWARDS
    • ROOKIE OF THE YEAR
    • PLANT OF THE YEAR
    • PROFESSIONAL OF THE YEAR
  • MORE
    • Expert Columns
    • NEWSLETTERS
    • QUALITY STORE
    • INDUSTRY LINKS
    • SPONSOR INSIGHTS
  • EMAG
    • eMAGAZINE
    • ARCHIVES
    • CONTACT
    • ADVERTISE
  • SIGN UP!
Test & Inspection

The Hough Transform in Machine Vision

Use good lighting and image preprocessing to get a strong signal before applying the Hough Transform.

By Ben Dawson
November 3, 2014

Suppose you want a machine vision system to automatically detect scratches on a plastic part such as a cell phone case. You know that the scratches will be nearly straight lines and that they can be low contrast and discontinuous. You can’t predict their orientations or lengths, but only scratches longer than some length must be reported.

You set up a machine vision system with part positioning, lighting, lens, camera, processor, and vision software, and do some experiments. As always, proper lighting is critical for showing the defects. For this task a low-angle ring light “catches” the raised edges of each scratch and so shows the scratch as brighter lines. This lighting also “catches” dust particles on the part.

TECH TIPS

Most machine vision algorithms don’t know about lines and use only local information.

So what we need is an algorithm that uses knowledge of lines to constrain which points are part of a line and a way to globally integrate local line segments into a reliable detection of scratches.

This is where the Hough Transform comes in.

The vision software improves and thresholds the scratch signals, so you easily see scratches—but the vision system doesn’t reliably detect them. Scratches appear as low-contrast, discontinuous line segments while dust appears as random points. Your mind knows about lines and can globally integrate local, low-contrast line segments into the reliable perception of lines. This ability was described by the Gestalt psychologists as “The Law of Continuity.”

Most machine vision algorithms don’t know about lines and use only local information. So what we need is an algorithm that, like your mind, uses knowledge of lines to constrain which points are part of a line and a way to globally integrate local line segments into a reliable detection of scratches. This sounds like a job for the Hough Transform.

Introducing Mr. Hough

The Hough (pronounced “Huff”) Transform is a clever way to improve image structure detection when the structure can be parameterized, that is, described by set of parameters in an equation. In the case of straight line scratches, a straight line equation, y = m*x + b, fits a scratch line with parameters m and b, where m is the line’s slope and b is the line’s intercept with the Y axis. The algorithm “knows” about straight lines from this equation.

The Hough Transform generates parameter values m and b for all lines that could go through each detected (by a threshold, in this example) image point. Each possible line through each point then votes for its m and b values in a parameter space of possible m and b values. We limit and quantize this parameter space to get an accumulator space which accumulates votes for m and b values. After all possible lines through all detected points have voted, the accumulator space is searched for peaks that indicate which pairs of m and b parameters got the most votes. A peaks indicates the presence of line and gives its parameters and so its equation in the image.

The Hough Transform integrates weak local signals – scratch and noise points – over the image, using the line equation to select where in the accumulator space the weak local signals are summed. This gives us a way to integrate local image measures into a reliable, global detection of scratch lines.

A Simple Example

At this point if you aren’t confused, you haven’t been paying attention. Here’s a simple example of detecting a 3-point line at 45 degrees in an otherwise blank image (see Figure 2). The detected points (red dots) have coordinates {1,1},{2,2}, and {3,3}. We set up an accumulator space for b = 0,1,2, and 3 (magenta). The slope of the line, m, is computed from b and the position of each detected point, p = 1,2, and 3. We quantize m into size angle ranges (sectors) of 30 degrees each (blue text and dotted line).

There are 4 possible values for b and 6 for m, so our accumulator space has 4 x 6 = 24 cells. These are initially set to all be 0. With 3 points the peak vote value in the accumulator space will be 3 (yellow line in input image and yellow highlight in accumulator space). The total number of counts in the accumulator space is p x b = 3 x 4 = 12.

The algorithm outline is:

Do for each point, p                // For all detected points in input image

Do for each intercept, b         // For all quantized Y intercepts

m = arctan( (p-b)/p )               // Computes quantized slope, m, in degrees

accumulator[m][b]++           // Increment the accumulator cell at location m,b

 

Try a few point and intercepts to see how this works. For example, the drawing shows the line for point p = 1 and parameter b = 2 (in green). Using these values m = arctan(-1) = -45 degrees. The dotted green line at -45 degrees shows m is between -60 to -30 degrees. Then use the two parameters m = -60…-30 and b = 2 to increment the accumulator table. This is shown by the green dotted arrow from the line to the accumulator and the green number in the accumulator.

I’ve made this example simple by using the familiar form of the line equation and limiting points and intercepts to the first quadrant. In practice, b values can be negative and the line equation y = mx + b can’t represent vertical lines as m would go to infinity. Instead a rho, theta parameterization of the line is used, where rho is the perpendicular distance from line to the origin and theta is the angle rho makes with the X axis. This gives a line equation of the form: rho = x cos(theta) + y sin(theta). At every x,y detected point and for every quantized theta angle, a quantized rho is generated and the accumulator space at rho, theta is incremented. This produces characteristic sinusoidal patterns in the accumulator space that intersect at detected line parameters

To Infinity and Beyond

Encouraged by the success of the Hough Transform in detecting broken lines in noisy images, we consider applying this method to circles. Circles have three parameters: (x,y) center and radius, so our parameter space is three-dimensional. Let’s see how this works.

Let’s suppose you have an 800 by 600 pixel image and you choose a quantization of 1 pixel for the radius and assume a maximum radius of 800. That means there are 800 x 600 x 800 bins in your accumulator space, so 384,000,000 bins. The accumulator can fit in main memory but the voting will be slow because cell access violates the assumptions of memory caching in the CPU. Then you have additional time to search that space for peaks. Most of the accumulator space will be empty but there is no way to skip empty memory, at least on a standard computer.

Undeterred, we try ellipse detection using the Hough Transform. Now there are five parameters: (x,y) center, lengths of the major and minor axes, and major axis orientation, which we will quantize to 180 angles. On the same 800 by 600 pixel image we now have a five-dimensional space of 800 x 600 x 800 x 600 x 180 = 41,472,000,000,000. Needless to say, that won’t work on any vision system I’m aware of; perhaps the NSA has something that could handle this?

In short, the Hough Transform “explodes” as you increase the number of parameters. A line transform can be practical on a vision system, but a straightforward circle transform is usually not.

There are many ways to reduce the accumulator size and processing time. The simplest are to reduce the range of your accumulator and to increase quantization bin size. For example, if the radius of a circular object, such as a rivet or fastener, is limited to a small range and if the position of the center of the circular object is also restricted, then the circle Hough Transform is much faster.

Local edge structure can be used to reduce voting. For a line, we might vote for an m only when p and b generate a line that matches the local edge orientation as computed from a 3x3 (pixel) edge detector. This reduces accumulator access time and also increases the size of the desired peak in the accumulator relative to the off-peak values and so makes line detection more robust.

Similarly, for circles, the local curvature of circle edge points can limit voting to only points with a selected range of radii (radius = 1/curvature). In any case, you are betting that the local edge structure is representative of the image structure you want to detect. You are trading robustness for speed and smaller memory size.

The Generalized Hough Transform (GHT) extends the idea of using edge orientation to reduce time and accumulator dimensions and allows the detection of arbitrary object shapes. The basic GHT computes a table that lists object edge points by pairs of angles and radii from an object edge point to a center point as a function of the orientation of the object edge. When recognizing an object, the edge orientation at an object edge point is used to “look up” the angle, radii pairs from the table which vote for the position the object center point, as in the regular Hough Transform. The peak in the vote accumulation space gives the x,y object position.

This method is the basis for some machine vision “search” algorithms, which learn the outline of an arbitrary shape and then find that outline shape in new images, assuming the object is in the image.

What to Expect in Practice

The voting process increases the correct peak bin but also “sprays” votes to off-peak bins. Off-line noise will generally accumulate in off-peak bins. When the line is short so the correct peak has few counts, the noise and “spray” into the off-peak bins can cause false line detection. You already know how to reduce this problem: use good lighting and image preprocessing to get a strong signal before applying the Hough Transform.

Peak detection is usually done with a threshold that can be tricky to set because the correct peak bin might not be that much greater than the off-peak bin values and the correct peak and noise bins will vary from image to image. Local maximum peak detection sometimes helps and sometimes causes line detection from off-peak bins, that is, noise. As the threshold decreases you will often see multiple lines being detected through the same image (scratch) line, as bins around the correct peak are now being used, and they have similar parameters and so give similar lines.

When properly done, the Hough Transform can seem to have magical powers of using local features to pull out global image patterns, such as lines, from background noise. 

References

Gestalt Psychology

Method and Means for Recognizing Complex Patterns, by Paul V. C. Hough, US Patent 3069654, December 1963.

Use of the Hough Transform to Detect Lines and Curves in Pictures, by Richard O. Duda and Peter E. Hart, Communications of the ACM, Vol. 15, Number 1., January 1972.

Hough Transform Paper

How the Hough Transform was Invented, by P.E. Hart, IEEE Signal Processing Magazine, Vol. 26, Issue 6, November 2009.

Hough Transform (A good introduction)

 Generalizing the Hough Transform to Detect Arbitrary Shapes, by D.H. Ballard, Pattern Recognition, Vol.13, No.2, p.111-122, 1981.

KEYWORDS: vision technology

Share This Story

Looking for a reprint of this article?
From high-res PDFs to custom plaques, order your copy today!

Ben Dawson is Director of strategic development for Teledyne DALSA Industrial Products Inc. [email protected].

Recommended Content

JOIN TODAY
to unlock your recommendations.

Already have an account? Sign In

  • 2024 Quality Rookie of the Year Justin Wise 1440x750px banner with "Quality Rookie of the Year" logo inset

    Meet the 2024 Quality Rookie of the Year: Justin Wise

    Justin Wise is an exceptional individual who has been...
    Aerospace
    By: Michelle Bangert
  • Man with umbrella and coat stands outside while it rains at night looking at a building.

    Nondestructive Testing: Is there an ethics problem?

    I was a whistleblower who exposed fraudulent activities...
    NDT
    By: Dale Norwood
  • Unraveling Deflategate: Football stadium with closeup of football on field

    Unraveling the Tom Brady Deflategate

    The Deflategate scandal erupted following the 2014 AFC...
    Measurement
    By: Greg Cenker and Henry Zumbrun
Manage My Account
  • eMagazine Subscriptions
  • Newsletters
  • Online Registration
  • Subscription Customer Service
  • Manage My Preferences

More Videos

Sponsored Content

Sponsored Content is a special paid section where industry companies provide high quality, objective, non-commercial content around topics of interest to the Quality audience. All Sponsored Content is supplied by the advertising company and any opinions expressed in this article are those of the author and not necessarily reflect the views of Quality or its parent company, BNP Media. Interested in participating in our Sponsored Content section? Contact your local rep!

close
  • Key Takeaways for Quality Leaders
    Sponsored byComplianceQuest

    Key Takeaways for Quality Leaders from the 2026 Gartner Magic Quadrant™ for QMS

  • This image shows a person seated next to a Bobcat T66 compact track loader.
    Sponsored byPolyWorks by InnovMetric

    Supercharging Digital Gauging at Bobcat North America

  • Dorsey Calibration Lab photo by Tom LaBarbera Picture this Studios
    Sponsored byDorsey Metrology International

    Ensuring Product Quality in a Competitive Manufacturing Landscape

Popular Stories

iStock-1352825159-jpg.jpg

U.S. Should Substantially Boost Support for Manufacturing USA Program, Issue National Industrial Manufacturing Strategy, Says New Report

Dorsey Calibration Lab photo by Tom LaBarbera Picture this Studios

Ensuring Product Quality in a Competitive Manufacturing Landscape

Visions Sensors Ebook

eBook | How AI-driven Vision Systems Are Transforming Automotive Quality Control

2026 Quality Professional of the Year!

Events

June 22, 2026

Automate 2026

Automate is North America's largest robotics and automation event — and the best place to take your ideas from insight to impact.
 
Our show floor features the world’s leading automation solutions, from AI and robotics to motion control, vision systems, and more. Plus, our educational conference is second to none, led by the brightest minds in automation today.
 
Ready to transform the way you work? Take the next step at Automate.
July 14, 2026

Quality Leaders Forum: Better Communication, Better Quality Data

The Quality Leaders Forum is a quarterly, editor-moderated fireside chat series hosted by Quality Magazine, featuring candid conversations with senior manufacturing and operations executives shaping enterprise-level quality.

View All Submit An Event

Products

Lean Manufacturing and Service Fundamentals, Applications, and Case Studies

Lean Manufacturing and Service Fundamentals, Applications, and Case Studies

See More Products
Quality Podcast Channel Custom Content

Related Articles

  • VS 0922 Analysis Manufacturing Floor

    Understanding The Value Proposition For Deep Learning in Machine Vision

    See More
  • GigE cameras

    Interfaces in Machine Vision: A Newcomer Disrupts the Market

    See More
  • Shape-based matching in blurred image.

    A Perfect Match: The Critical Role of Matching in Machine Vision Technologies

    See More

Related Products

See More Products
  • Machine Vision and Error Proofing DVD

  • ZEuCDwAAQBAJ.jpg

    Lean Six Sigma In The Age Of Artificial Intelligence: Harnessing The Power Of The Fourth Industrial Revolution

See More Products

Related Directories

  • Machine Vision Store

    Machine Vision Store has a laser-sharp focus on machine vision imaging. We deliver a select group of components - cameras, lenses, lights, industrial vision PC's - from leading manufacturers known for quality. Components we understand, support and stand behind. Components and consulting services that will power your success.
×

Stay in the know with Quality’s comprehensive coverage of
the manufacturing and metrology industries.

Newsletters | Website | eMagazine

JOIN TODAY!
  • RESOURCES
    • Advertise
    • Contact Us
    • Directories
    • Manufacturing Division
    • Store
    • Want More
  • SIGN UP TODAY
    • Create Account
    • eMagazine
    • Newsletters
    • Customer Service
    • Manage Preferences
  • SERVICES
    • Marketing Services
    • Market Research
    • Reprints
    • List Rental
    • Survey/Respondent Access
  • STAY CONNECTED
    • LinkedIn
    • Facebook
    • YouTube
    • X (Twitter)
  • PRIVACY
    • PRIVACY POLICY
    • TERMS & CONDITIONS
    • DO NOT SELL MY PERSONAL INFORMATION
    • PRIVACY REQUEST
    • ACCESSIBILITY

Copyright ©2026. All Rights Reserved BNP Media, Inc. and BNP Media II, LLC.

Design, CMS, Hosting & Web Development :: ePublishing