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

#### 15.5.180 esegment

```esegment(data [, sign=sign, diagonal=diagonal, threshold=threshold])```

Extreme-based data segmentation in multiple dimensions. `esegment(data)` returns the number of directions through each element of `data` in which the element is a local maximum compared to its immediate neighbors in each direction. For example, in two dimensions we can regard the data as an altitude map, and then this function checks if the central value exceeds the two adjacent values on opposite sides of the central value in the n-s direction, the e-w direction, the ne-sw direction, and the nw-se direction. The number of directions to consider per data element in an `n`-dimensional array is equal to `m = (3^n - 1)/2`.

If `diagonal` is specified, then it must be an array with one element per dimension of `data`. The elements that are equal to 0 indicate which dimensions are not checked. The elements that are equal to 1 and 2 (after conversion to type `long`) indicate in which dimensions checking is performed. The elements that are equal to 2 indicate in which dimensions checked directions may be diagonal. All such directions either have non-zero coordinates only in those dimensions, or have only a single non-zero coordinate (i.e., a non-diagnonal direction). Only approved directions are checked. For instance, if `diagonal = [2,2,0]`, then the only checked directions that have a non-zero third coordinate are those that are along the 3rd axis. If `diagonal = [1,1,0]`, then only directions along the first two axes are checked. If `diagonal` contains `n1` ones and `n2` twos, then the number of directions per data element in `n` dimensions that will be considered is equal to `m = (3^n2 - 1)/2 + n1`.

If `sign` (when converted to type `long`) is non-zero, then minima are sought. If integer `sign` is negative, then maxima are sought. By default, a value of `+1` is assumed for `sign`.

Zeros are returned on the 1-px-wide edges of the result, because not enough data is available there to determine the extremeness in all directions.