ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/ran2tiff.csh
Revision: 2.1
Committed: Sat Sep 17 05:14:14 2005 UTC (18 years, 7 months ago) by greg
Content type: application/x-csh
Branch: MAIN
CVS Tags: rad3R8
Log Message:
Created ran2tiff script for batch animation exposure and conversion

File Contents

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