| author | Axel Jacobs <axel@jaloxa.eu> |
| Sun, 15 Dec 2013 18:04:49 +0000 | |
| changeset 45 | aaf822f49732 |
| parent 0 | 0aa115157c9c |
| permissions | -rw-r--r-- |
|
0
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
1 |
#!/bin/csh -fe |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
2 |
# Convert Radiance animation frames to TIFF output |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
3 |
# |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
4 |
set histosiz=200 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
5 |
set pfwt=0.9 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
6 |
set outdir="" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
7 |
set pcopts=() |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
8 |
set tfopts=() |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
9 |
if (! $#argv) set argv=(DUMMY) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
10 |
# Process options for pcond and ra_tiff |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
11 |
while ("$argv[1]" =~ -*)
|
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
12 |
switch ("$argv[1]")
|
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
13 |
case -W: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
14 |
shift argv |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
15 |
set pfwt=$argv[1] |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
16 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
17 |
case -H: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
18 |
shift argv |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
19 |
set histof=$argv[1]:q |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
20 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
21 |
case -D: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
22 |
shift argv |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
23 |
if (! -d $argv[1]:q ) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
24 |
echo "Directory $argv[1] does not exist" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
25 |
exit 1 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
26 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
27 |
set outdir=$argv[1]:q/ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
28 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
29 |
case -h*: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
30 |
case -a*: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
31 |
case -v*: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
32 |
case -s*: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
33 |
case -c*: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
34 |
case -l*: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
35 |
set pcopts=($pcopts $argv[1]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
36 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
37 |
case -u: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
38 |
case -d: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
39 |
case -f: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
40 |
set pcopts=($pcopts $argv[1-2]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
41 |
shift argv |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
42 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
43 |
case -p: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
44 |
shift argv |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
45 |
set pcopts=($pcopts -p $argv[1-6]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
46 |
shift argv; shift argv; shift argv; shift argv; shift argv |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
47 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
48 |
case -z: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
49 |
case -b: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
50 |
case -w: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
51 |
set tfopts=($tfopts $argv[1]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
52 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
53 |
case -g: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
54 |
shift argv |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
55 |
set tfopts=($tfopts -g $argv[1]) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
56 |
breaksw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
57 |
default: |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
58 |
echo "$0: bad option: $argv[1]" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
59 |
exit 1 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
60 |
endsw |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
61 |
shift argv |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
62 |
end |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
63 |
if ($#argv < 2) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
64 |
echo Usage: "$0 [-W prev_frame_wt][-H histo][-D dir][pcond opts][ra_tiff opts] frame1 frame2 .." |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
65 |
exit 1 |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
66 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
67 |
# Get shrunken image luminances |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
68 |
set vald=`mktemp -d /tmp/val.XXXXXX` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
69 |
foreach inp ($argv:q) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
70 |
set datf="$inp:t" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
71 |
set datf="$vald/$datf:r.dat" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
72 |
pfilt -1 -x 128 -y 128 -p 1 $inp:q \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
73 |
| pvalue -o -h -H -b -df \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
74 |
| rcalc -if1 -e 'L=$1*179;cond=L-1e-7;$1=log10(L)' \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
75 |
> $datf:q |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
76 |
end |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
77 |
# Get Min. and Max. log values |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
78 |
set Lmin=`cat $vald/*.dat | total -l | rcalc -e '$1=$1-.01'` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
79 |
set Lmax=`cat $vald/*.dat | total -u | rcalc -e '$1=$1+.01'` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
80 |
if ($?histof) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
81 |
if (-r $histof) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
82 |
# Fix min/max and translate histogram |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
83 |
set Lmin=`sed -n '1p' $histof | rcalc -e 'min(a,b):if(a-b,b,a);$1=min($1,'"$Lmin)"` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
84 |
set Lmax=`sed -n '$p' $histof | rcalc -e 'max(a,b):if(a-b,a,b);$1=max($1,'"$Lmax)"` |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
85 |
tabfunc -i hfunc < $histof > $vald/oldhist.cal |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
86 |
cnt $histosiz \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
87 |
| rcalc -e "L10=$Lmin+($Lmax-$Lmin)/$histosiz"'*($1+.5)' \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
88 |
-f $vald/oldhist.cal -e '$1=L10;$2=hfunc(L10)' \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
89 |
> $vald/oldhisto.dat |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
90 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
91 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
92 |
foreach inp ($argv:q) |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
93 |
set datf="$inp:t" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
94 |
set datf="$vald/$datf:r.dat" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
95 |
set outp="$inp:t" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
96 |
set outp="$outdir$outp:r.tif" |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
97 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
98 |
histo $Lmin $Lmax $histosiz < $datf > $vald/newhisto.dat |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
99 |
if (-f $vald/oldhisto.dat) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
100 |
rlam $vald/newhisto.dat $vald/oldhisto.dat \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
101 |
| rcalc -e '$1=$1;$2=$2+$4*'$pfwt \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
102 |
> $vald/histo.dat |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
103 |
else |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
104 |
mv $vald/{new,}histo.dat
|
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
105 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
106 |
pcond $pcopts -I $inp:q < $vald/histo.dat \ |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
107 |
| ra_tiff $tfopts - $outp:q |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
108 |
mv $vald/{,old}histo.dat
|
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
109 |
end |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
110 |
if ($?histof) then |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
111 |
cp -f $vald/oldhisto.dat $histof |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
112 |
endif |
|
0aa115157c9c
Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff
changeset
|
113 |
rm -rf $vald |