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