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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <imhdr.h>
task mktest = t_mktest,
sigl2 = t_sigl2,
wrimage = t_wrimage,
zscale = t_zscale,
rcur = t_rcur
define TWOPI 6.23
# MKTEST -- Make a test image containing a circularly symetric sinusoid.
procedure t_mktest()
char imname[SZ_FNAME]
int nx, ny
int i, j
real period, xcen, ycen, radius
pointer im, line
int clgeti()
real clgetr()
pointer immap(), impl2r()
begin
call clgstr ("imname", imname, SZ_FNAME)
im = immap (imname, NEW_IMAGE, 0)
nx = clgeti ("nx")
ny = clgeti ("ny")
period = clgetr ("period")
IM_LEN(im,1) = nx
IM_LEN(im,2) = ny
xcen = (nx + 1) / 2.0
ycen = (ny + 1) / 2.0
do j = 1, ny {
line = impl2r (im, j)
do i = 1, nx {
radius = sqrt ((i - xcen) ** 2 + (j - ycen) ** 2)
Memr[line+i-1] = sin ((radius / period) * TWOPI) * 255.0
}
}
call imunmap (im)
end
# READ -- Benchmark scaled input procedure.
procedure t_sigl2 ()
char imname[SZ_FNAME]
pointer im, si, buf
int i, nx, ny, xblk, yblk
pointer sigl2_setup(), sigl2s(), immap()
begin
call clgstr ("imname", imname, SZ_FNAME)
im = immap (imname, READ_ONLY, 0)
nx = IM_LEN(im,1)
ny = IM_LEN(im,2)
xblk = INDEFI
yblk = INDEFI
si = sigl2_setup (im, 1.0,real(nx),nx,xblk, 1.0,real(ny),ny,yblk,0)
do i = 1, ny
buf = sigl2s (si, i)
call sigl2_free (si)
call imunmap (im)
end
# WRIMAGE -- Benchmark image output as used in the display program.
procedure t_wrimage ()
char imname[SZ_FNAME]
int i, ncols, nlines
pointer im, buf
int clgeti()
pointer immap(), imps2s()
begin
call clgstr ("imname", imname, SZ_FNAME)
im = immap (imname, NEW_IMAGE, 0)
ncols = clgeti ("ncols")
nlines = clgeti ("nlines")
IM_LEN(im,1) = ncols
IM_LEN(im,2) = nlines
IM_PIXTYPE(im) = TY_SHORT
do i = 1, nlines
buf = imps2s (im, 1, ncols, i, i)
call imunmap (im)
end
# ZSCALE -- Test the zscale procedure, used to determine the smallest range of
# greyscale values which preserves the most information in an image.
procedure t_zscale()
char imname[SZ_FNAME]
int sample_size, len_stdline
real z1, z2, contrast
int clgeti()
real clgetr()
pointer im, immap()
begin
call clgstr ("imname", imname, SZ_FNAME)
im = immap (imname, READ_ONLY, 0)
sample_size = clgeti ("npix")
len_stdline = clgeti ("stdline")
contrast = clgetr ("contrast")
call zscale (im, z1, z2, contrast, sample_size, len_stdline)
call printf ("z1=%g, z2=%g\n")
call pargr (z1)
call pargr (z2)
end
# RCUR -- Try reading the image cursor.
procedure t_rcur()
real x, y
int wcs, key
int wci, pause
char device[SZ_FNAME]
char strval[SZ_LINE]
bool clgetb()
int btoi(), clgeti(), imdrcur()
begin
call clgstr ("device", device, SZ_FNAME)
wci = clgeti ("wcs")
pause = btoi (clgetb ("pause"))
while (imdrcur (device, x,y,wcs,key,strval,SZ_LINE, wci,pause) != EOF) {
call printf ("%8.2f %8.2f %d %o %s\n")
call pargr (x)
call pargr (y)
call pargi (wcs)
call pargi (key)
call pargstr (strval)
if (key == 'q')
break
}
end
|