aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/lz/amapd.x
blob: 8f766793baa90e1f9bbeb387fbe4894be906c48e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

# AMAP -- Vector linear transformation.  Map the range of pixel values
# a1,a2 from a into the range b1,b2 in b.  It is assumed that a1 < a2
# and b1 < b2.

procedure amapd (a, b, npix, a1, a2, b1, b2)

double	a[ARB], b[ARB]
double	a1, a2, b1, b2

double	minout, maxout, aoff, boff, pixval

double	scalar

int	npix, i

begin
	    scalar = (double (b2) - double (b1)) / (double (a2) - double (a1))

	minout = min (b1, b2)
	maxout = max (b1, b2)
	aoff = a1
	boff = b1

	do i = 1, npix {
	    pixval = (a[i] - aoff) * scalar
	    b[i] = max(minout, min(maxout, pixval + boff))
	}
end