Next: find_min, Previous: find_max, Up: Internal Routines [Contents][Index]

`find_maxloc(`

`data` [, diagonal=`diagonal`, /degree,
/subgrid, /coords, /old])

By default, seeks local maxima in

and returns their
positions as indices to `data``data`

. If `/coords`

is specified,
then returns coordinates to `data`

in an array with the different
coordinates in the first dimension (i.e., if `x`

is the result,
then `x(*,0)`

contains the first coordinate of each found position.
`data`

must be numerical and may have multiple dimensions.

If

is specified, then it must be an array with one
element per dimension of `diagonal`

. The elements that are equal
to 0 indicate which dimensions are not checked for a local maximum. The
elements that are equal to 1 and 2 (after conversion to type
`data``long`

) indicate in which dimensions checking is performed. The
elements that are equal to 2 indicate in which dimensions checked
directions may be diagonal. Elements equal to 1 indicate that no
diagonals are allowed in those dimensions. All such directions either
have non-zero coordinate offsets only in those dimensions, or have only
a single non-zero coordinate offset (i.e., a non-diagnonal or orthogonal
direction). Only approved directions are checked. If

contains `diagonal``n1`

ones and `n2`

twos, then
the number of directions per data element in `n`

dimensions that
will be considered is equal to `m = 2^n2 - 1 + n1`

.

For example, regard a two-dimensional array. We’ll call the first
dimension the east-west direction and the second one the north-south
dimension. Then, if

, all points are
returned that are local maxima in the east-west direction without
regards to any other direction. If `diagonal` = [1,0]

, then
all points are returned that are local maxima in the east-west direction
and also in the north-south direction, without regards to the other
(northeast-southwest, southeast-northwest) directions. If
`diagonal` = [1,1]

, then all directions are checked.
`diagonal` = [2,2]

For a three-dimensional array, if

, then
the only checked directions that have a non-zero third coordinate offset
are those that are along the 3rd axis. If `diagonal` = [2,2,1]

, then only directions along the first two axes are checked.
`diagonal` =
[1,1,0]

If `/degree`

is specified, then the number of directions per data
element where the data shows a local maximum is returned instead. This
number always lies between 0 and the total number `m`

of directions
given above. `find_maxloc(`

returns an
array with 1s at all positions returned by
`data`, /degree) eq m`find_maxloc(`

, but the latter form is considerably
faster because for each element it stops checking as soon as a direction
without a local maximum is found. For noise data in arbitrary numbers
of dimensions, on average at most 2 local maximum comparisons per data
element are performed, compared to `data`)`m`

, which is grows
exponentially with the number of dimensions in the worst case, if
`/degree`

is specified.

If `/subgrid`

is specified, then the value of the local maximum is
taken from a quadratic hypersurface fitted to the local neighborhood of
the local maximum.

The used algorithm decides whether a particular data point is a local maximum by looking at its nearest neighbors only. This means that it cannot decide if a region in which all adjacent data values are equal constitutes a local maximum. Such regions are ignored.

If `/old`

is specified, then an older algorithm for two-dimensional

is used instead, which always returns indices to
`data``data`

(as if `/coords`

is not specified). In that case, each
value that is larger than the eight values immediately surrounding it is
a local maximum. The edges of the image are not considered. Of a
multi-pixel local maximum, only one position is returned. Of a plateau
that is larger than three by three pixels, the algorithm cannot
determine whether it is a local maximum or not, and one position in the
plateau is returned.

See also: find, local_max, find_max, find_minloc

Next: find_min, Previous: find_max, Up: Internal Routines [Contents][Index]