diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/plio/tf/plp2rs.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/plio/tf/plp2rs.x')
-rw-r--r-- | sys/plio/tf/plp2rs.x | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/sys/plio/tf/plp2rs.x b/sys/plio/tf/plp2rs.x new file mode 100644 index 00000000..da082f47 --- /dev/null +++ b/sys/plio/tf/plp2rs.x @@ -0,0 +1,71 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <plset.h> +include <plio.h> + +# PL_P2R -- Convert a pixel array to a range list. The length of the output +# range list is returned as the function value. + +int procedure pl_p2rs (px_src, xs, rl, npix) + +short px_src[ARB] #I input pixel array +int xs #I starting index in pixbuf +short rl[3,ARB] #O destination range list +int npix #I number of pixels to convert + +short hi, pv, zero +int xe, x1, np, rn, nv, ip +define done_ 91 + +begin + # No input pixels? + if (npix <= 0) + return (0) + + xe = xs + npix - 1 + rn = RL_FIRST + + # Pack the pixel array into a range list. This is done by scanning + # the pixel list for successive ranges of pixels of constant nonzero + # value, where each range is described as follows: + + zero = 0 + pv = max (zero, px_src[xs]) # pixel value of current range + x1 = xs # start index of current range + hi = 1 # current high value + + # Process the data array. + do ip = xs, xe { + if (ip < xe) { + # Get the next pixel value, loop again if same as previous one. + nv = max (zero, px_src[ip+1]) + if (nv == pv) + next + + # If current range is zero, loop again to get nonzero range. + if (pv == 0) { + pv = nv + x1 = ip + 1 + next + } + } + + np = ip - x1 + 1 + + # Output the new range. + if (pv > 0) { + rl[1,rn] = x1 + rl[2,rn] = np + rl[3,rn] = pv + rn = rn + 1 + } + + x1 = ip + 1 + pv = nv + } + + RL_LEN(rl) = rn - 1 + RL_AXLEN(rl) = npix + + return (rn - 1) +end |