This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

vision.HoughLines System object

Package: vision

Find Cartesian coordinates of lines that are described by rho and theta pairs


The HoughLines object finds Cartesian coordinates of lines that are described by rho and theta pairs. The object inputs are the theta and rho values of lines and a reference image. The object outputs the one-based row and column positions of the intersections between the lines and two of the reference image boundary lines. The boundary lines are the left and right vertical boundaries and the top and bottom horizontal boundaries of the reference image.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


H = vision.HoughLines returns a Hough lines System object, H, that finds Cartesian coordinates of lines that are described by rho and theta pairs.

H = vision.HoughLines(Name,Value) returns a Hough lines object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).



Method to calculate sine values used to find intersections of lines

Specify how to calculate sine values which are used to find intersection of lines as Trigonometric function, or Table lookup. If this property is set to Trigonometric function, the object computes sine and cosine values it needs to calculate the intersections of the lines. If it is set to Table lookup, the object computes and stores the trigonometric values it needs to calculate the intersections of the lines in a table and uses the table for each step call. In this case, the object requires extra memory. For floating-point inputs, this property must be set to Trigonometric function. For fixed-point inputs, the property must be set to Table lookup. The default is Table lookup.


Spacing of the theta-axis

Specify the spacing of the theta-axis. This property applies when you set the SineComputation property to Table lookup.

 Fixed-Point Properties


stepOutput intersection coordinates of a line described by a theta and rho pair and reference image boundary lines
Common to All System Objects

Create System object with same property values


Expected number of inputs to a System object


Expected number of outputs of a System object


Check locked states of a System object (logical)


Allow System object property value changes


expand all

Read the intensity image.

    I = imread('circuit.tif');

Create an edge detector, Hough transform, local maxima finder, and Hough lines objects.

    hedge = vision.EdgeDetector;
    hhoughtrans = vision.HoughTransform(pi/360,'ThetaRhoOutputPort', true);
    hfindmax = vision.LocalMaximaFinder(1,	'HoughMatrixInput', true);
    hhoughlines = vision.HoughLines('SineComputation','Trigonometric function');
Warning: The vision.EdgeDetector will be removed in a future release. Use the
edge function with equivalent functionality instead. 
Warning: The vision.HoughTransform will be removed in a future release. Use the
hough function with equivalent functionality instead. 

Find the edges in the intensity image

 	BW = step(hedge, I);

Run the edge output through the transform

	[ht, theta, rho] = step(hhoughtrans, BW);

Find the location of the max value in the Hough matrix.

 	idx = step(hfindmax, ht);

Find the longest line.

 	linepts = step(hhoughlines, theta(idx(1)-1), rho(idx(2)-1), I);

View the image superimposed with the longest line.

   imshow(I); hold on;
   line(linepts([1 3])-1, linepts([2 4])-1,'color',[1 1 0]);


This object implements the algorithm, inputs, and outputs described on the Hough Lines block reference page. The object properties correspond to the block parameters.

Extended Capabilities

Introduced in R2012a

Was this topic helpful?