orig/pveil.csh
author Axel Jacobs <axel@jaloxa.eu>
Mon, 14 Apr 2014 22:21:17 +0100
changeset 73 87fa3132a136
parent 0 0aa115157c9c
permissions -rw-r--r--
New IES test file with spaces in file name
     1 #!/bin/csh -f
     2 # RCSid: $Id: pveil.csh,v 3.4 2008/11/10 19:08:19 greg Exp $
     3 #
     4 # Add veiling glare to picture
     5 #
     6 if ($#argv != 1) then
     7 	echo "Usage: $0 input.hdr > output.hdr"
     8 	exit 1
     9 endif
    10 set ifile=$1
    11 set td=/tmp
    12 set gf=$td/av$$.gs
    13 set cf=$td/av$$.cal
    14 set tf=($gf $cf)
    15 onintr quit
    16 findglare -r 400 -c -p $ifile \
    17 	| sed -e '1,/^BEGIN glare source$/d' -e '/^END glare source$/,$d' \
    18 	> $gf
    19 if ( -z $gf ) then
    20 	cat $ifile
    21 	goto quit
    22 endif
    23 ( rcalc -e '$1=recno;$2=$1;$3=$2;$4=$3;$5=$4*$5' $gf \
    24 	| tabfunc SDx SDy SDz I ; cat ) > $cf << '_EOF_'
    25 N : I(0);
    26 K : 9.2;	{ should be 9.6e-3/PI*(180/PI)^2 == 10.03 ? }
    27 bound(a,x,b) : if(a-x, a, if(x-b, b, x));
    28 Acos(x) : acos(bound(-1,x,1));
    29 sq(x) : x*x;
    30 mul(ct) : if(ct-cos(.5*PI/180), K/sq(.5), K/sq(180/PI)*ct/sq(Acos(ct)));
    31 Dx1 = Dx(1); Dy1 = Dy(1); Dz1 = Dz(1);		{ minor optimization }
    32 cosa(i) = SDx(i)*Dx1 + SDy(i)*Dy1 + SDz(i)*Dz1;
    33 sum(i) = if(i-.5, mul(cosa(i))*I(i)+sum(i-1), 0);
    34 veil = le(1)/WE * sum(N);
    35 ro = ri(1) + veil;
    36 go = gi(1) + veil;
    37 bo = bi(1) + veil;
    38 '_EOF_'
    39 getinfo < $ifile | egrep '^((VIEW|EXPOSURE|PIXASPECT|PRIMARIES|COLORCORR)=|[^ ]*(rpict|rview|pinterp) )'
    40 pcomb -f $cf $ifile
    41 quit:
    42 rm -f $tf