peaks = houghpeaks(H,numpeaks) locates
peaks in the Hough transform matrix, H, generated
by the hough function. numpeaks specifies
the maximum number of peaks to identify. The function returns peaks a
matrix that holds the row and column coordinates of the peaks.

peaks = houghpeaks(___,Name,Value,...) locates
peaks in the Hough transform matrix, where named parameters control
aspects of the operation.

Find peaks in the Hough transform of the image and plot them.

P = houghpeaks(H,2);
imshow(H,[],'XData',T,'YData',R,'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
plot(T(P(:,2)),R(P(:,1)),'s','color','white');

Hough transform matrix, specified as a numeric array of class double.
The rows and columns correspond to rho and theta values.
Use the hough function to create a Hough transform
matrix.

Data Types: double

numpeaks — Maximum number of peaks to identify 1 (default) | positive integer scalar

Maximum number of peaks to identify, specified as a numeric
scalar.

Data Types: double

Name-Value Pair Arguments

Specify optional
comma-separated pairs of Name,Value arguments. Name is
the argument name and Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN.

Example: P = houghpeaks(H,2,'Threshold',15);

'Threshold' — Minimum value to be considered a peak 0.5*max(H(:)) (default) | nonnegative numeric scalar

Minimum value to be considered a peak, specified as a nonnegative
numeric scalar. The value can be any value between 0
and Inf.

Data Types: double

'NHoodSize' — Size of suppression neighborhood smallest odd values greater than or equal to
size(H)/50 (default) | two-element vector of positive odd integers

Size of suppression neighborhood, specified as a two-element vector of
positive odd integers. The suppression
neighborhood is the neighborhood around each peak that
is set to zero after the peak is identified.

Hough transform theta values, specified as a vector returned by the
hough function. Each element of the vector
specifies the theta value for the corresponding
column of the output matrix H.
houghpeaks uses the theta
values specified for peak suppression.

Note

If you specify the 'Theta' parameter as input
to the hough function, you must specify the
theta parameter with the
houghpeaks function. Use the
theta output value from the
hough function as the
theta input value for
houghpeaks. Otherwise, peak suppression can
result in unexpected results.

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.