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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <imhdr.h>
# XT_21IMSUM -- Sum 2D image columns or lines to 1D.
procedure xt_21imsum (im, axis, col1, col2, line1, line2, x, y, npts)
pointer im # IMIO pointer
int axis # Axis of vector
int col1, col2 # Range of columns
int line1, line2 # Range of lines
pointer x # Vector ordinates
pointer y # Vector abscissa
int npts # Number of points in vector
int i, line, ncols, nlines
real asumr()
pointer imgs2r()
begin
# If the pointers are defined first free them.
call mfree (x, TY_REAL)
call mfree (y, TY_REAL)
ncols = col2 - col1 + 1
nlines = line2 - line1 + 1
switch (axis) {
case 1:
npts = ncols
call malloc (x, ncols, TY_REAL)
call calloc (y, ncols, TY_REAL)
do i = 1, ncols
Memr[x+i-1] = col1 + i - 1
do i = 1, nlines {
line = line1 + i - 1
call aaddr (Memr[imgs2r (im, col1, col2, line, line)], Memr[y],
Memr[y], ncols)
}
case 2:
npts = nlines
call malloc (x, nlines, TY_REAL)
call malloc (y, nlines, TY_REAL)
do i = 1, nlines {
line = line1 + i - 1
Memr[x+i-1] = line
Memr[y+i-1] = asumr (Memr[imgs2r (im, col1, col2, line, line)],
ncols)
}
}
end
# XT_21IMMED -- Median 2D image columns or lines to 1D.
define MAXPIX 10000 # Maximum number of pixels to read at one time.
procedure xt_21immed (im, axis, col1, col2, line1, line2, x, y, npts)
pointer im # IMIO pointer
int axis # Axis of vector
int col1, col2 # Range of columns
int line1, line2 # Range of lines
pointer x # Vector ordinates
pointer y # Vector abscissa
int npts # Number of points in vector
int i, j, k, n, line, ncols, nlines, maxncols
pointer buf1, buf2
real amedr()
pointer imgs2r()
begin
# If the pointers are defined first free them.
call mfree (x, TY_REAL)
call mfree (y, TY_REAL)
ncols = col2 - col1 + 1
nlines = line2 - line1 + 1
switch (axis) {
case 1:
npts = ncols
call malloc (x, ncols, TY_REAL)
call calloc (y, ncols, TY_REAL)
call malloc (buf1, nlines, TY_REAL)
maxncols = MAXPIX / nlines
j = 0
do i = 1, ncols {
if (i > j) {
n = min (ncols - j, maxncols)
buf2 = imgs2r (im, col1+j, col1+j+n-1, line1, line2)
j = j + n
}
do k = 1, nlines
Memr[buf1+k-1] = Memr[buf2+(k-1)*n+i-1]
Memr[y+i-1] = amedr (Memr[buf1], nlines)
}
call mfree (buf1, TY_REAL)
do i = 1, ncols
Memr[x+i-1] = col1 + i - 1
case 2:
npts = nlines
call malloc (x, nlines, TY_REAL)
call malloc (y, nlines, TY_REAL)
do i = 1, nlines {
line = line1 + i - 1
Memr[x+i-1] = line
Memr[y+i-1] = amedr (Memr[imgs2r (im, col1, col2, line, line)],
ncols)
}
}
end
# XT_21IMAVG -- Average 2D image columns or lines to 1D.
procedure xt_21imavg (im, axis, col1, col2, line1, line2, x, y, npts)
pointer im # IMIO pointer
int axis # Axis of vector
int col1, col2 # Range of columns
int line1, line2 # Range of lines
pointer x # Vector ordinates
pointer y # Vector abscissa
int npts # Number of points in vector
begin
call xt_21imsum (im, axis, col1, col2, line1, line2, x, y, npts)
switch (axis) {
case 1:
call adivkr (Memr[y], real (line2-line1+1), Memr[y], npts)
case 2:
call adivkr (Memr[y], real (col2-col1+1), Memr[y], npts)
}
end
|