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 zero-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.
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.
|clone||Create hough lines object with same property values|
|getNumInputs||Number of expected inputs to step method|
|getNumOutputs||Number of outputs from step method|
|isLocked||Locked status for input attributes and nontunable properties|
|release||Allow property value and input characteristics changes|
|step||Output intersection coordinates of a line described by a theta and rho pair and reference image boundary lines|
Use Hough lines to detect the longest line in an image. Use the edge detection object to find edges in the intensity image. The step method outputs a binary image required by the HoughTransform object and improves the efficiency of the HoughLines object.
I = imread('circuit.tif'); hedge = vision.EdgeDetector; hhoughtrans = vision.HoughTransform(pi/360,'ThetaRhoOutputPort', true); hfindmax = vision.LocalMaximaFinder(1, 'HoughMatrixInput', true); hhoughlines = vision.HoughLines('SineComputation','Trigonometric function'); % 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.