CImage:FindFirst
The FindFirst method returns the array position of the first element inside a range of value, having value <= nHigh and >= nLow. The first element is at array position 1. If the pixel is not found, 0 is returned.
nPos = CImage:FindFirst( sComp, nValue ) |
nPos = CImage:FindFirst( sComp, nHigh, nLow ) |
where |
sComp is the comparison (see below).
nValue is the target value.
nHigh is the high target value.
nLow is the low target value.
nPos is the integral position of the element. On success, nPos > 0; on failure, nPos = 0.
This method locates the first pixel satisfyiong the comparision to the target value(s). The return value is a linear position in the array. If the search fails, 0 is returned. For a multi-dimensional array, the position can be converted to a coordinate location using CoordOf.
FindFirst Comparisons
Comparison |
Condition for returning nOffset < 0 |
< |
Pixel value < nLow |
<= |
Pixel value <= nLow |
> |
Pixel value > nHigh |
>= |
Pixel value >= nHigh |
== |
Pixel value == nLow |
~= |
Pixel value ~= nLow |
<> |
Pixel value inside the range nLow to nHigh. |
>< |
Pixel value outside the range nLow to nHigh. |
The following script opens a 3-D image from the file sPath, then searches for the first element with value <= 300 and >= -100. The script converts the offset to a multi-dimensional coordinate and prints it. Note that 3 coordinates are listed in this case, which presumes that the image has 3 dimensions. Since CoordOf returns the coordinates as a table, multiple table elements can be printed by listing CoordOf as the last item in the call list for Printf.
|
-- Create a CImage |
|
-- Open the image from sPath. |
|
-- Find the first element <= 300 and >= -100 |
|
-- if found then |
|
-- assumes there are 3 dimensions |
|
|