aboutsummaryrefslogtreecommitdiff
path: root/pkg/obsolete/imcombine/icgrow.gx
blob: 8b28aec5fea15a1d32e1e1be11bc027af80832e8 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<imhdr.h>
include	<pmset.h>
include	"../icombine.h"

# IC_GROW --  Mark neigbors of rejected pixels.
# The rejected pixels (original plus grown) are saved in pixel masks.

procedure ic_grow (out, v, m, n, buf, nimages, npts, pms)

pointer	out			# Output image pointer
long	v[ARB]			# Output vector
pointer	m[ARB]			# Image id pointers
int	n[ARB]			# Number of good pixels
int	buf[npts,nimages]	# Working buffer
int	nimages			# Number of images
int	npts			# Number of output points per line
pointer	pms			# Pointer to array of pixel masks

int	i, j, k, l, line, nl, rop, igrow, nset, or()
real	grow2, i2
pointer	mp, pm, pm_newmask()
errchk	pm_newmask()

include	"../icombine.com"

begin
	if (dflag == D_NONE || grow == 0.)
	    return

	line = v[2]
	nl = IM_LEN(out,2)
	rop = or (PIX_SRC, PIX_DST)

	igrow = grow
	grow2 = grow**2
	do l = 0, igrow {
	    i2 = grow2 - l * l
	    call aclri (buf, npts*nimages)
	    nset = 0
	    do j = 1, npts {
		do k = n[j]+1, nimages {
		    mp = Memi[m[k]+j-1]
		    if (mp == 0)
			next
		    do i = 0, igrow {
			if (i**2 > i2)
			    next
			if (j > i)
			    buf[j-i,mp] = 1
			if (j+i <= npts)
			    buf[j+i,mp] = 1
			nset = nset + 1
		    }
		}
	    }
	    if (nset == 0)
		return

	    if (pms == NULL) {
		call malloc (pms, nimages, TY_POINTER)
		do i = 1, nimages
		    Memi[pms+i-1] = pm_newmask (out, 1)
	    }
	    do i = 1, nimages {
		pm = Memi[pms+i-1]
		v[2] = line - l
		if (v[2] > 0)
		    call pmplpi (pm, v, buf[1,i], 1, npts, rop)
		v[2] = line + l
		if (v[2] <= nl)
		    call pmplpi (pm, v, buf[1,i], 1, npts, rop)
	    }
	}
	v[2] = line
end


$for (sird)
# IC_GROW$T --  Reject pixels.

procedure ic_grow$t (v, d, m, n, buf, nimages, npts, pms)

long	v[ARB]			# Output vector
pointer	d[ARB]			# Data pointers
pointer	m[ARB]			# Image id pointers
int	n[ARB]			# Number of good pixels
int	buf[ARB]		# Buffer of npts
int	nimages			# Number of images
int	npts			# Number of output points per line
pointer	pms			# Pointer to array of pixel masks

int	i, j, k
pointer	pm
bool	pl_linenotempty()

include	"../icombine.com"

begin
	do k = 1, nimages {
	    pm = Memi[pms+k-1]
	    if (!pl_linenotempty (pm, v))
		next
	    call pmglpi (pm, v, buf, 1, npts, PIX_SRC)
	    do i = 1, npts {
		if (buf[i] == 0)
		    next
		for (j = 1; j <= n[i]; j = j + 1) {
		    if (Memi[m[j]+i-1] == k) {
			if (j < n[i]) {
			    Mem$t[d[j]+i-1] = Mem$t[d[n[i]]+i-1]
			    Memi[m[j]+i-1] = Memi[m[n[i]]+i-1]
			}
			n[i] = n[i] - 1
			dflag = D_MIX
			break
		    }
		}
	    }
	}
end
$endfor