Main Content

houghpeaks

Identify peaks in Hough transform

Description

example

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

peaks= houghpeaks(H,numpeaks,Name,Value)controls aspects of the operation using name-value pair arguments.

Examples

collapse all

Read image into workspace.

I = imread('circuit.tif');

Create binary image.

BW = edge(imrotate(I,50,'crop'),'canny');

Create Hough transform of image.

[H,T,R] = hough(BW);

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(‘\θ), ylabel('\rho'); axison, axisnormal, holdon; plot(T(P(:,2)),R(P(:,1)),'s','color','white');

Figure contains an axes object. The axes object contains 2 objects of type image, line.

Input Arguments

collapse all

Hough transform matrix, specified as a numeric array. The rows and columns correspond torhoandtheta弗吉尼亚州lues. Use thehoughfunction to create a Hough transform matrix.

Data Types:double

Maximum number of peaks to identify, specified as a positive integer.

Data Types:double

Name-Value Arguments

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

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

Minimum value to be considered a peak, specified as a nonnegative number.

Data Types:double

Size of the suppression neighborhood, specified as a 2-element vector of positive odd integers. Thesuppression neighborhoodis the neighborhood around each peak that is set to zero after the peak is identified. The default value ofNHoodSizeis the smallest odd values greater than or equal tosize(H)/50. The dimensions ofNHoodSizemust be smaller than the size of the Hough transform matrix,H.

Data Types:double

Hough transform theta values, specified as a numeric vector returned by thehoughfunction. Each element of the vector specifies thetheta弗吉尼亚州lue for the corresponding column of the output matrixH.houghpeaks使用theta弗吉尼亚州lues specified for peak suppression. Use thehoughfunction to create a Hough transform matrix.

Note

If you specify the“θ”parameter as input to thehoughfunction, you must specify thethetaparameter with thehoughpeaksfunction. Use thethetaoutput value from thehoughfunction as thethetainput value forhoughpeaks. Otherwise, peak suppression can result in unexpected results.

Data Types:double

Output Arguments

collapse all

Row and column coordinates of found peaks, returned as aQ-by-2 matrix. The valueQcan range from0tonumpeaks.

Extended Capabilities

Version History

Introduced before R2006a

See Also

|