diff options
Diffstat (limited to 'sys/imio/imbtran.x')
-rw-r--r-- | sys/imio/imbtran.x | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/sys/imio/imbtran.x b/sys/imio/imbtran.x new file mode 100644 index 00000000..bf3ec201 --- /dev/null +++ b/sys/imio/imbtran.x @@ -0,0 +1,65 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <imhdr.h> +include <imset.h> +include <imio.h> + +# IMBTRAN -- Transform a point (x,y), possibly lying outside the boundary of +# the N-dimensional image, back into the image using the current boundary +# extension technique. + +procedure imbtran (im, v1, v2, ndim) + +pointer im # image descriptor +long v1[IM_MAXDIM] # input, out of bounds point +long v2[IM_MAXDIM] # transformed point (output) +int ndim # number of dimensions to transform + +int i +long vin, vmax + +begin + switch (IM_VTYBNDRY(im)) { + case BT_NEAREST: + do i = 1, ndim { + vmax = IM_SVLEN(im,i) + vin = v1[i] + + if (vin < 1) + v2[i] = 1 + else if (vin > vmax) + v2[i] = vmax + else + v2[i] = vin + } + + case BT_REFLECT: + do i = 1, ndim { + vmax = IM_SVLEN(im,i) + vin = v1[i] + + if (vin < 1) + v2[i] = 1 + (1 - vin) + else if (vin > vmax) + v2[i] = vmax - (vin - vmax) + else + v2[i] = vin + } + + case BT_WRAP: + do i = 1, ndim { + vmax = IM_SVLEN(im,i) + vin = v1[i] + + while (vin < 1) + vin = vin + vmax + while (vin > vmax) + vin = vin - vmax + v2[i] = vin + } + + default: + do i = 1, ndim + v2[i] = v1[i] + } +end |