Hough Transform
The Standard Hough Transform (SHT) is designed to detect straight lines in images. The SHT uses the parametric representation of a line:
rho = x*cos(theta) + y*sin(theta)
theta is the angle of the perpendicular projection from the origin
to the line, measured in degrees clockwise from the positive
x-axis. rho is the parallel offset from the
origin to the line along a vector perpendicular to the line. The magnitude of
rho is equivalent to the perpendicular distance between the
origin and the line. The following image depicts how theta and
rho are defined relative to the perpendicular projection of a
line.

You can perform the Hough transform of a binary image by using the hough function. The hough function returns a
parameter space matrix whose rows and columns correspond to these rho
and theta values, respectively. For every combination of
rho and theta, the SHT calculates the line
with those parameters and returns the sum of all true pixels in the
input binary image along that line.
After you calculate the Hough transform, you can find peak values in the parameter
space matrix by using the houghpeaks function. These peaks
represent potential lines in the input image. However, a peak does not guarantee a line
in the input image, because a peak could result from an accumulation of many short
co-linear line segments.
To get more information about the line segments contributing to peaks in the Hough
matrix, you can use the houghlines function. For each line
segment that corresponds to a peak, the houghlines function returns
the (x, y) coordinates of the two endpoints of the
line segment and the values of theta and rho for
the line. The houghlines function reduces the effect of noise in
the input binary image by automatically connecting line segments with small gaps between
them. You can use the information about endpoints to identify the longest lines in an
image or to display the line segments over the input image. For an example, see Detect Lines and Highlight Longest Segment Using Hough Transform.
See Also
hough | houghlines | houghpeaks