Identify peaks in Hough transform


  • peaks = houghpeaks(H,numpeaks)
  • peaks = houghpeaks(___,Name,Value,...)



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.

Code Generation support: Yes.

MATLAB Function Block support: Yes.


collapse all

Locate and Display Peaks in Hough Transform of Rotated Image

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);
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;

Input Arguments

collapse all

H — Hough transform matrixnumeric array

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 identify1 (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 single 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 peak0.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 neighborhoodsmallest 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.

Data Types: double

Output Arguments

collapse all

peaks — Row and column coordinates of peaks found Q-by-2 matrix

Row and column coordinates of peaks found, returned as a Q-by-2 matrix, where the value Q can range from 0 to numpeaks.

More About

collapse all

Code Generation

This function supports the generation of C code using MATLAB® Coder™. For more information, see Code Generation for Image Processing.

The optional parameter names 'Threshold' and 'NHoodSize' must be compile-time string constants. Their associated values need not be compile-time constants.

MATLAB Function Block

You can use this function in the MATLAB Function Block in Simulink.

See Also


Introduced before R2006a

Was this topic helpful?