Find Local Maxima

Find local maxima in matrices

Library

Statistics

`visionstatistics`

Description

The Find Local Maxima block finds the local maxima within an input matrix. It does so by comparing the maximum value in the matrix to a user-specified threshold. The block considers a value to be a valid local maximum when the maximum value is greater than or equal to the specified threshold. The determination of the local maxima is based on the neighborhood, an area around and including the maximum value. After finding the local maxima, the block sets all the matrix values in the neighborhood, including the maximum value, to `0`. This step ensures that subsequent searches do not include this maximum. The size of the neighborhood must be appropriate for the data set. That is, the threshold must eliminate enough of the values around the maximum so that false peaks are not discovered. The process repeats until the block either finds all valid maximas or the number of local maximas equal the Maximum number of local maxima value. The block outputs one-based [x y] coordinates of the maxima. The data to all input ports must be the same data type.

If the input to this block is a Hough matrix output from the Hough Transform block, select the Input is Hough matrix spanning full theta range check box. If you select this check box, the block assumes that the Hough port input is antisymmetric about the rho axis and theta ranges from -pi/2 to pi/2 radians. If the block finds a local maxima near the boundary, and the neighborhood lies outside the Hough matrix, then the block detects only one local maximum. It ignores the corresponding antisymmetric maximum.

Dialog Box

The Find Local Maxima dialog box appears as shown in the following figure.

Maximum number of local maxima

Specify the maximum number of maxima you want the block to find.

Neighborhood size

Specify the size of the neighborhood around the maxima over which the block zeros out the values. Enter a two-element vector of positive odd integers, [rc]. Here, r represents the number of rows in the neighborhood, and c represents the number of columns.

Source of threshold value

Specify how to enter the threshold value. If you select ```Input port```, the Th port appears on the block. If you select `Specify via dialog`, the Threshold parameter appears in the dialog box. Enter a scalar value that represents the value all maxima should meet or exceed.

Threshold

Enter a scalar value that represents the value all maxima should meet or exceed. This parameter is visible if, for the Source of threshold value parameter, you choose ```Specify via dialog```.

Input is Hough matrix spanning full theta range

If you select this check box, the block assumes that the Hough port input is antisymmetric about the rho axis and theta ranges from -pi/2 to pi/2 radians.

Index output data type

Specify the data type of the Idx port output. Your choices are `double`, `single`, `uint8`, `uint16`, or `uint32`.

Output variable size signal

Specify output data type. When you uncheck the Output variable size signal, the Count output data type parameter appears in the dialog box.

Count output data types

Specify the data type of the Count port output. Your choices are `double`, `single`, `uint8`, `uint16`, or `uint32`. This parameter applies when you clear the Output variable size signal check box.

Examples

See Detect Lines in Images and Measure Angle Between Lines in the Computer Vision System Toolbox™ User's Guide.

Supported Data Types

The block outputs the one-based [x y] coordinates of the maxima at the Idx port and the number of valid local maxima found at the Count port.

PortInput/OutputSupported Data TypesComplex Values Supported

I/Hough

Matrix in which you want to find the maxima.

• Double-precision floating point

• Single-precision floating point

• Fixed point

• 8-, 16-, 32-bit signed integer

• 8-, 16-, 32-bit unsigned integer

No

Th

Scalar value that represents the value the maxima should meet or exceed.

Same as I/Hough port

No

Idx

An M-by-2 matrix of one-based [x y] coordinates, where M represents the number of local maximas found.

• Double-precision floating point

• Single-precision floating point

• 8-, 16-, and 32-bit unsigned integer

No

Count

Scalar value that represents the number of maxima that meet or exceed the threshold value.

Same as Idx port

No

 Hough Lines Computer Vision System Toolbox Hough Transform Computer Vision System Toolbox Corner Detection Computer Vision System Toolbox `houghpeaks` Image Processing Toolbox™ `vision.CornerDetector` Computer Vision System Toolbox `vision.HoughLines` Computer Vision System Toolbox `vision.HoughTransform` Computer Vision System Toolbox