Next: segmentdir, Previous: sdev, Up: Internal Routines [Contents][Index]
segment(data [, sign=sign, diagonal=diagonal,
/degree])
Curvature-based data segmentation in multiple dimensions.
segment(data)
returns a 1
for each element of
n
-dimensional data
where the data in an
n-dimensional hypercube with sides of 3 elements centered on the element
under investigation shows curvature of the appropriate sign in all
directions through that central element, and a 0
otherwise. For
each direction, the curvature is equal to the sum of the values of two
elements adjacent on opposite sides to the central element minus twice
the central value. For example, in two dimensions we can regard the
data as an altitude map, and then this function returns a 1
in
all places where the central value exceeds the average of 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 data
is equal to m = (3^n
- 1)/2
.
If diagonal
is specified, then it must have one element per
data dimension and is taken as instructions on which nearest-neighbor
connections to recognize. A 2
means that nearest neighbors with
their bitmap
values equal to 1
are assigned to the
same area if they share any face or vertex in the corresponding
dimension. A 1
means that such neighbors are assigned to the
same area only if they share a face in the corresponding dimension. a
0
means that connections in the corresponding dimension are
ignored. If diagonal
is not specified, then code 2
is assumed for all dimensions.
For example, if diagonal
is equal to [2, 2, 0]
, then
no connections in the third dimension are recognized, and the data is
treated as a set of unconnected two-dimensional images (but no area in
any of these images shares its area number with any area in any of the
other images). Within each of the images, connections in all four
directions (n-s, e-w, ne-sw, nw-se) are recognized in this case. If
diagonal
is equal to [1, 1, 0]
, then only directions
in the orthogonal directions (n-s, e-w) are recognized. Likewise for
[2, 1, 0]
, because even though the first dimension allowes
vertices, the second one only accepts faces.
If /degree
is specified, then the number of directions per data
element that exhibit the appropriate curvature is returned instead.
This number always lies between 0 and the total number m
of
directions given above. segment(data, /degree) eq m
is
equivalent to segment(data)
, but the latter form is usually
considerably faster because for each element it stops checking as soon
as a direction with inappropriate curvature is found. For noise data in
arbitrary numbers of dimensions, on average at most 2 curvature
calculations per data element are performed.
If sign
(when converted to type long
) is non-zero,
then negative curvature (i.e., hill-like objects) are sought. If
integer sign
is negative, then positive curvature (i.e.,
valley-like objects) 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 curvature in all directions.
If data
is a 2-dimensional array and neither
diagonal
nor /degree
are specified, then a
special-purpose version of the routine is used that is optimized for
processing speed. In all other cases a more general but slower version
is executed.
If data
is of types long
, float
, or
double
, then overflow problems may occur if any of its
values have a magnitude exceeding #max_long/2
,
#max_float/2
, or #max_double/2
, respectively.
Next: segmentdir, Previous: sdev, Up: Internal Routines [Contents][Index]