find_elements

advertisement
FIND_ELEMENTS
Function to return the array subscripts for elements in one
array that are found in another array. The first argument is
the array to be searched, the second argument is the list of
values to search for, and if a third array argument is
provided then the elements of the first array will be
adjusted to its values. The elements of the second and third
arrays correspond one-to-one, that is, those elements in the
first array found to be equal to the first element of the
second array will be adjusted to the value of the first
element of the third array (see the examples!).
This routine is useful for identifying regions-of-interest
(ROIs) in an image array and possibly modifying their values.
Because the search for elements in the second array must be
performed iteratively, this routine will be quite slow if
the number of elements in the second (and possibly third)
arguments is large.
Note that the number of elements in the second and third
array arguments must be the same since there is a one-to-one
correspondence between them.
Calling Sequence
Subscrips = FIND_ELEMENTS(Array, Tofind [, Adjust])
Arguments
Array
This is the array to be searched, in which elements
will be found which appear in the argument Tofind.
Tofind
This is the list of values which will be searched
for in Array. If the number of elements is large
then this routine will be quite slow.
Adjust
This optional argument is a list of values to which
the elements of Array that are found to be in the
array Tofind will be adjust to. These elements
correspond one-to-one with the elements of Tofind;
elements of Array found equal to the first element
of Tofind will be adjusted to the first element of
Adjust, etc. The number of elements of Adjust and
Tofind must be the same.
Outputs
Returns the subscripts of elements in argument Array
that are found in the array Tofind. If no elements
are found then returns -1. If one of the arguments
is inappropriate or the number of elements in
arguments two and three are not the same returns -2.
Elements of the argument Array will be adjusted if
the optional third argument is supplied.
Examples
To find the elements of array Image that are equal to
the values 0,1,2,3,4:
Roi = FIND_ELEMENTS(Image, [0,1,2,3,4])
You could then add to each element with the following:
Image(Roi) = Image(Roi) + 10
but it is easier to accomplish this with:
Roi = FIND_ELEMENTS(Image, [0,1,2,3,4], [10,11,12,13,14])
Download