Find local maxima in matrices

Statistics

`visionstatistics`

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.

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, [

*r**c*]. 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.

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

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.

Port | Input/Output | Supported Data Types | Complex 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 |

| Scalar value that represents the value the maxima should meet or exceed. | Same as I/Hough port | No |

| An | Double-precision floating point Single-precision floating point 8-, 16-, and 32-bit unsigned integer
| No |

| Scalar value that represents the number of maxima that meet or exceed the threshold value. | Same as Idx port | No |

Computer Vision System Toolbox | |

Computer Vision System Toolbox | |

Computer Vision System Toolbox | |

Image Processing Toolbox™ | |

`vision.CornerDetector` | Computer Vision System Toolbox |

`vision.HoughLines` | Computer Vision System Toolbox |

`vision.HoughTransform` | Computer Vision System Toolbox |

Was this topic helpful?