M-File Help: Hough View code for Hough

Hough

Hough transform class

The Hough transform is a technique for finding lines in an image using a voting scheme. For every edge pixel in the input image a set of cells in the Hough accumulator (voting array) are incremented.

In this version of the Hough transform lines are described by:

d = y cos(theta) + x sin(theta)

where theta is the angle the line makes to horizontal axis, and d is the perpendicular distance between (0,0) and the line. A horizontal line has theta = 0, a vertical line has theta = pi/2 or -pi/2.

The voting array is 2-dimensional, with columns corresponding to theta and rows corresponding to offset (d). Theta spans the range -pi/2 to pi/2 in Ntheta steps. Offset is in the range -rho_max to rho_max where rho_max=max(W,H).

Methods

plot Overlay detected lines
show Display the Hough accumulator
lines Return line features
char Convert Hough parameters to string
display Display Hough parameters

Properties

Nrho Number of bins in rho direction
Ntheta Number of bins in theta direction
A The Hough accumulator (Nrho x Ntheta)
rho rho values for the centre of each bin vertically
theta Theta values for the centre of each bin horizontally
edgeThresh Threshold on relative edge pixel strength
houghThresh Threshold on relative peak strength
suppress Radius of accumulator cells cleared around peak
interpWidth Width of region used for peak interpolation

Notes

See also

LineFeature


Hough.Hough

Create Hough transform object

ht = Hough(E, options) is the Hough transform of the edge image E.

For every pixel in the edge image E (HxW) greater than a threshold the corresponding elements of the accumulator are incremented. By default the vote is incremented by the edge strength but votes can be made equal with the option 'equal'. The threshold is determined from the maximum edge strength value x ht.edgeThresh.

Options

'equal' All edge pixels have equal weight, otherwise the edge pixel value is the vote strength
'points' Pass set of points rather than an edge image, in this case E (2xN) is a set of N points, or E (3xN) is a set of N points with corresponding vote strengths as the third row
'interpwidth', W Interpolation width (default 3)
'houghthresh', T Set HT.houghThresh (default 0.5)
'edgethresh', T Set HT.edgeThresh (default 0.1);
'suppress', W Set HT.suppress (default 0)
'nbins', N Set number of bins, if N is scalar set Nrho=Ntheta=N, else N = [Ntheta, Nrho]. Default 400x401.

Hough.char

Convert to string

s = HT.char() is a compact string representation of the Hough transform parameters.


Hough.display

Display value

HT.display() displays a compact human-readable string representation of the Hough transform parameters.

Notes

See also

Hough.char


Hough.lines

Find lines

L = HT.lines() is a vector of LineFeature objects that represent the dominant lines in the Hough accumulator.

L = HT.lines(n) as above but returns no more than n LineFeature objects.

Lines are the coordinates of peaks in the Hough accumulator. The highest peak is found, refined to subpixel precision, then all elements in an HT.suppress radius around are zeroed so as to eliminate multiple close minima. The process is repeated for all peaks.

The peak detection loop breaks early if the remaining peak has a strength less than HT.houghThresh times the maximum vote value.

See also

Hough.plot, LineFeature


Hough.plot

Plot line features

HT.plot() overlays all detected lines on the current figure.

HT.plot(n) overlays a maximum of n strongest lines on the current figure.

HT.plot(n, ls) as above but the optional line style arguments ls are passed to plot.

H = HT.plot() as above but returns a vector of graphics handles for each line.

See also

Hough.lines


Hough.show

Display the Hough accumulator as image

s = HT.show() displays the Hough vote accumulator as an image using the hot colormap, where 'heat' is proportional to the number of votes.

See also

colormap, hot


 

© 1990-2012 Peter Corke.