Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# vision.LocalMaximaFinder System object

Package: vision

Find local maxima in matrices

## Description

The LocalMaximaFinder object finds local maxima in matrices.

After constructing the object and optionally setting properties, use the step method to find the coordinates of the local maxima in the input image. Use the step syntax below with input matrix, I, LocalMaximaFinder object, H, and any optional properties.

 IDX = step(H,I) returns [x y] coordinates of the local maxima in an M-by-2 matrix, IDX. M represents the number of local maximas found. The maximum value of M may not exceed the value set in the MaximumNumLocalMaxima property.
 [...] = step(H,I,THRESH) finds the local maxima in input image I, using the threshold value THRESH, when you set the ThresholdSource property to Input port.

## Construction

H = vision.LocalMaximaFinder returns a local maxima finder System object, H, that finds local maxima in input matrices.

H = vision.LocalMaximaFinder(Name,Value) returns a local maxima finder object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

H = vision.LocalMaximaFinder(MAXNUM,NEIGHBORSIZE,Name,Value) returns a local maxima finder object, H, with the MaximumNumLocalMaxima property set to MAXNUM, NeighborhoodSize property set to NEIGHBORSIZE, and other specified properties set to the specified values.

## Properties

 MaximumNumLocalMaxima Maximum number of maxima to find Specify the maximum number of maxima to find as a positive scalar integer value. The default is 2. NeighborhoodSize Neighborhood size for zero-ing out values Specify the size of the neighborhood around the maxima, over which the System object zeros out values, as a 2-element vector of positive odd integers. The default is [5 7]. ThresholdSource Source of threshold Specify how to enter the threshold value as Property, or Input port. The default is Property. Threshold Value that all maxima should match or exceed Specify the threshold value as a scalar of MATLAB® built-in numeric data type. This property applies when you set the ThresholdSource property to Property. The default is 10. This property is tunable. HoughMatrixInput Indicator of Hough Transform matrix input Set this property to true if the input is antisymmetric about the rho axis and the theta value ranges from to radians, which correspond to a Hough matrix. When you set this property to true, the object assumes a Hough matrix input . The block applies additional processing, specific to Hough transform on the right and left boundaries of the input matrix. The default is false. IndexDataType Data type of index values Specify the data type of index values as double, single , uint8, uint16, or uint32. The default is uint32.

## Methods

 clone Create local maxima finder object with same property values getNumInputs Number of expected inputs to step method getNumOutputs Number of outputs from step method isLocked Locked status for input attributes and nontunable properties release Allow property value and input characteristics changes step Find local maxima in input image

## Examples

Find a local maxima in an input.

```      I = [0 0 0 0 0 0 0 0 0 0 0 0; ...
0 0 0 1 1 2 3 2 1 1 0 0; ...
0 0 0 1 2 3 4 3 2 1 0 0; ...
0 0 0 1 3 5 7 5 3 1 0 0; ... % local max at x=7, y=4
0 0 0 1 2 3 4 3 2 1 0 0; ...
0 0 0 1 1 2 3 2 1 1 0 0; ...
0 0 0 0 0 0 0 0 0 0 0 0];

hLocalMax = vision.LocalMaximaFinder;
hLocalMax.MaximumNumLocalMaxima = 1;
hLocalMax.NeighborhoodSize = [3 3];
hLocalMax.Threshold = 1;

location = step(hLocalMax, I)
```

## Algorithms

This object implements the algorithm, inputs, and outputs described on the Find Local Maxima block reference page. The object properties correspond to the block parameters.