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
|
include <imhdr.h>
# CCDMEAN -- Compute mean and add to header if needed.
procedure ccdmean (input)
char input[ARB] # Input image
int i, nc, nl, hdmgeti()
long time, clktime()
bool clgetb()
real mean, hdmgetr(), asumr()
pointer in, immap(), imgl2r()
errchk immap
begin
# Check if this operation has been done.
in = immap (input, READ_WRITE, 0)
ifnoerr (mean = hdmgetr (in, "ccdmean")) {
iferr (time = hdmgeti (in, "ccdmeant"))
time = IM_MTIME(in)
if (time >= IM_MTIME(in)) {
call imunmap (in)
return
}
}
if (clgetb ("noproc")) {
call eprintf (
" [TO BE DONE] Compute mean of image\n")
call pargstr (input)
call imunmap (in)
return
}
# Compute and record the mean.
nc = IM_LEN(in,1)
nl = IM_LEN(in,2)
mean = 0.
do i = 1, nl
mean = mean + asumr (Memr[imgl2r(in,i)], nc)
mean = mean / (nc * nl)
time = clktime (long(0))
call hdmputr (in, "ccdmean", mean)
call hdmputi (in, "ccdmeant", int (time))
call imunmap (in)
end
|