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
|
#{ FLATTEN -- Divide images by a flat field
#images,s,a,,,,Images to be flattened
#flatfield,f,a,,,,Flat field
#minflat,r,h,INDEF,,,Minimum flat field value
#pixtype,s,h,"real",,,Flattened image pixel datatype
#keeplog,b,h,@generic.keeplog,,,Keep log of processing?
#logfile,f,h,@generic.logfile,,,Log file
#imlist,f,h
#imfd,*s,h
#input,f,h
#flat,f,h
#flt,f,h
{
# Startup message.
if (keeplog) {
time (>> logfile)
print (" FLATTEN: Flatten images.", >> logfile)
}
# Set temporary files.
imlist = mktemp ("tmp$ims")
# Replace low flat field values if needed.
flat = flatfield
if (minflat == INDEF)
flt = flat
else {
if (keeplog)
print (" Minimum flat field value = ", minflat, >> logfile)
flt = mktemp ("tmp$ims")
imcopy (flat, flt, verbose=no)
imreplace (flt, 1., upper=minflat)
}
# Generate image list.
sections (images, option="fullname", >imlist)
imfd = imlist
while (fscan (imfd, input) != EOF) {
# Print output.
if (keeplog) {
time (>> logfile)
print (" Flatten ", input, " with ", flat, ".", >> logfile)
}
# Flatten the image with the flat field. Replace the input
# image by the flattened image.
imarith (input, "/", flt, input, pixtype=pixtype, calctype="real")
}
if (minflat != INDEF)
imdelete (flt, verify=no)
delete (imlist, verify=no)
# Ending message.
if (keeplog) {
time (>> logfile)
print (" FLATTEN: Done.", >> logfile)
}
}
|