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