aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/ak/agltd.x
blob: c307fe7d2e9aba8a942b8288b9c04a2543abd176 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

# AGLT -- Given a list of ranges, replace the value of each input pixel
# which falls within a given range by applying the corresponding linear
# transformation (b = a * kmul + kadd).  If KMUL is identically zero,
# B is replaced by the constant KADD.

procedure agltd (a, b, npix, low, high, kmul, kadd, nrange)

double	a[ARB], b[ARB], pixval
int	npix, i
double	low[nrange], high[nrange]	# range limits
double	kmul[nrange], kadd[nrange]	# linear transformation
int	nrange, nr

begin
	do i = 1, npix {
	    pixval = a[i]
	    b[i] = pixval
	    do nr = 1, nrange
		if (pixval >= low[nr] && pixval <= high[nr]) {
			if (kmul[nr] == 0.0D0)
			    b[i] = kadd[nr]
			else
			    b[i] = (pixval * kmul[nr]) + kadd[nr]
			break
		}
	}
end