aboutsummaryrefslogtreecommitdiff
path: root/pkg/images/imutil/src/imasub.gx
blob: 4eb2a2c23d167554ecb6a00dc5b9b4892633e48c (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<imhdr.h>

# IMA_SUB -- Image arithmetic subtraction.

$for (silrd)
procedure ima_sub$t (im_a, im_b, im_c, a, b)

pointer	im_a, im_b, im_c
PIXEL	a, b

int	len
pointer	im[3], buf[3]
long	v[IM_MAXDIM, 3]

int	ima_nl$t()

begin
	# Loop through all of the image lines.
	im[1] = im_c
	len = IM_LEN (im[1], 1)
	call amovkl (long(1), v, 3 * IM_MAXDIM)

	# If imagea is constant then read imageb.  Do a vector/scalar
	# subtraction and then negate the result.
	if (im_a == NULL) {
	    im[2] = im_b
	    while (ima_nl$t (im, buf, v, 2) != EOF) {
		if (a != 0$f) {
		    call asubk$t (Mem$t[buf[2]], a, Mem$t[buf[1]], len)
		    call aneg$t (Mem$t[buf[1]], Mem$t[buf[1]], len)
		} else
		    call aneg$t (Mem$t[buf[2]], Mem$t[buf[1]], len)
	    }

	# If imageb is constant then read imagea and do a vector/scalar
	# subtraction to imagec.
	} else if (im_b == NULL) {
	    im[2] = im_a
	    while (ima_nl$t (im, buf, v, 2) != EOF) {
		if (b == 0$f)
		    call amov$t (Mem$t[buf[2]], Mem$t[buf[1]], len)
		else
		    call asubk$t (Mem$t[buf[2]], b, Mem$t[buf[1]], len)
	    }

	# Read imagea and imageb and do a vector subtraction into imagec.
	} else {
	    im[2] = im_a
	    im[3] = im_b
	    while (ima_nl$t (im, buf, v, 3) != EOF)
		call asub$t (Mem$t[buf[2]], Mem$t[buf[3]], Mem$t[buf[1]], len)
	}
end
$endfor