ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/falsecolor.csh
(Generate patch)

Comparing ray/src/px/falsecolor.csh (file contents):
Revision 1.6 by greg, Tue May 28 16:06:46 1991 UTC vs.
Revision 2.16 by greg, Mon Nov 13 02:41:46 2006 UTC

# Line 1 | Line 1
1 < #!/bin/csh -f
2 < # SCCSid "$SunId$ LBL"
1 > #!/bin/csh -fe
2 > # RCSid: $Id$
3   #
4   # Create false color image with legend
5   #
6 < set td=/usr/tmp/fc$$
6 > # Added user-definable legend 2004/01/20 Rob Guglielmetti
7 >
8 > set td=/tmp/fc$$
9   onintr quit
10 < set mult=470
10 > set mult=179
11   set label=Nits
12   set scale=1000
13   set decades=0
14 < set redv='1.6*v-.6'
15 < set grnv='if(v-.375,1.6-1.6*v,8/3*v)'
16 < set bluv='1-8/3*v'
14 > set redv='def_red(v)'
15 > set grnv='def_grn(v)'
16 > set bluv='def_blu(v)'
17   set ndivs=8
18   set picture='-'
19   set cpict=
20 + set loff=0
21   set legwidth=100
22   set legheight=200
23   while ($#argv > 0)
24          switch ($argv[1])
25 +        case -lw:
26 +                shift argv
27 +                set legwidth="$argv[1]"
28 +                breaksw
29 +        case -lh:
30 +                shift argv
31 +                set legheight="$argv[1]"
32 +                breaksw
33          case -m:
34                  shift argv
35                  set mult="$argv[1]"
# Line 26 | Line 37 | while ($#argv > 0)
37          case -s:
38                  shift argv
39                  set scale="$argv[1]"
40 +                if ("$scale" =~ [aA]*) set needfile
41                  breaksw
42          case -l:
43                  shift argv
# Line 47 | Line 59 | while ($#argv > 0)
59                  shift argv
60                  set bluv="$argv[1]"
61                  breaksw
62 +        case -spec:
63 +                shift argv
64 +                set redv='1.6*v-.6'
65 +                set grnv='if(v-.375,1.6-1.6*v,8/3*v)'
66 +                set bluv='1-8/3*v'
67 +                breaksw
68          case -i:
69                  shift argv
70                  set picture="$argv[1]"
# Line 63 | Line 81 | while ($#argv > 0)
81                  breaksw
82          case -cl:
83                  set docont=a
84 +                set loff=12
85                  breaksw
86          case -cb:
87                  set docont=b
88 +                set loff=13
89                  breaksw
90 +        case -e:
91 +                set doextrem
92 +                set needfile
93 +                breaksw
94          case -n:
95                  shift argv
96                  set ndivs="$argv[1]"
97                  breaksw
98          default:
99 <                echo bad option "'$argv[1]'" >/dev/tty
99 >                echo bad option "'$argv[1]'"
100                  exit 1
101          endsw
102          shift argv
103   end
104   mkdir $td
105 + if ($?needfile && "$picture" == '-') then
106 +        cat > $td/picture
107 +        set picture=$td/picture
108 + endif
109 + if ("$scale" =~ [aA]*) then
110 +        set LogLmax=`phisto $picture | tail -2 | sed -n '1s/    [0-9]*$//p'`
111 +        set scale=`ev "$mult/179*10^$LogLmax"`
112 + endif
113   cat > $td/pc0.cal <<_EOF_
114 + PI : 3.14159265358979323846 ;
115   scale : $scale ;
116   mult : $mult ;
117   ndivs : $ndivs ;
# Line 86 | Line 119 | ndivs : $ndivs ;
119   or(a,b) : if(a,a,b);
120   EPS : 1e-7;
121   neq(a,b) : if(a-b-EPS,1,b-a-EPS);
122 < btwn(a,b) : if(a-x,-1,b-x);
122 > btwn(a,x,b) : if(a-x,-1,b-x);
123   clip(x) : if(x-1,1,if(x,x,0));
124   frac(x) : x - floor(x);
125 < boundary(a,b) : neq(floor(ndivs*a),floor(ndivs*b));
125 > boundary(a,b) : neq(floor(ndivs*a+.5),floor(ndivs*b+.5));
126  
127 + interp_arr2(i,x,f):(i+1-x)*f(i)+(x-i)*f(i+1);
128 + interp_arr(x,f):if(x-1,if(f(0)-x,interp_arr2(floor(x),x,f),f(f(0))),f(1));
129 + def_redp(i):select(i,0.18848,0.05468174,
130 + 0.00103547,8.311144e-08,7.449763e-06,0.0004390987,0.001367254,
131 + 0.003076,0.01376382,0.06170773,0.1739422,0.2881156,0.3299725,
132 + 0.3552663,0.372552,0.3921184,0.4363976,0.6102754,0.7757267,
133 + 0.9087369,1,1,0.9863);
134 + def_red(x):interp_arr(x/0.0454545+1,def_redp);
135 + def_grnp(i):select(i,0.0009766,2.35501e-05,
136 + 0.0008966244,0.0264977,0.1256843,0.2865799,0.4247083,0.4739468,
137 + 0.4402732,0.3671876,0.2629843,0.1725325,0.1206819,0.07316644,
138 + 0.03761026,0.01612362,0.004773749,6.830967e-06,0.00803605,
139 + 0.1008085,0.3106831,0.6447838,0.9707);
140 + def_grn(x):interp_arr(x/0.0454545+1,def_grnp);
141 + def_blup(i):select(i,0.2666,0.3638662,0.4770437,
142 + 0.5131397,0.5363797,0.5193677,0.4085123,0.1702815,0.05314236,
143 + 0.05194055,0.08564082,0.09881395,0.08324373,0.06072902,
144 + 0.0391076,0.02315354,0.01284458,0.005184709,0.001691774,
145 + 2.432735e-05,1.212949e-05,0.006659406,0.02539);
146 + def_blu(x):interp_arr(x/0.0454545+1,def_blup);
147 +
148   isconta = if(btwn(0,v,1),or(boundary(vleft,vright),boundary(vabove,vbelow)),-1);
149   iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),-1);
150  
97 ro = if(in,clip($redv),ra);
98 go = if(in,clip($grnv),ga);
99 bo = if(in,clip($bluv),ba);
100
151   ra = 0;
152   ga = 0;
153   ba = 0;
154  
155   in = 1;
156 +
157 + ro = if(in,clip($redv),ra);
158 + go = if(in,clip($grnv),ga);
159 + bo = if(in,clip($bluv),ba);
160   _EOF_
161   cat > $td/pc1.cal <<_EOF_
162   norm : mult/scale/le(1);
# Line 130 | Line 184 | if ("$cpict" == "") then
184   else if ("$cpict" == "$picture") then
185          set cpict=
186   endif
187 < if ($decades > 0) then
187 > if ("$decades" != "0") then
188          set pc1args=($pc1args -e "map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)")
189          set imap="imap(y)=10^((y-1)*$decades)"
190   else
191          set imap="imap(y)=y"
192   endif
193 + if ( $legwidth > 20 && $legheight > 40 ) then
194   pcomb $pc0args -e 'v=(y+.5)/yres;vleft=v;vright=v' \
195                  -e 'vbelow=(y-.5)/yres;vabove=(y+1.5)/yres' \
196                  -x $legwidth -y $legheight > $td/scol.pic
197 < ( echo $label; cnt $ndivs \
197 > ( echo "$label"; cnt $ndivs \
198                  | rcalc -e '$1='"($scale)*imap(($ndivs-.5-"'$1'")/$ndivs)" \
199 <                -e "$imap" ) \
200 <        | psign -cf 1 1 1 -cb 0 0 0 -h `ev "floor(2*$legheight/$ndivs+.5)"` \
201 <        | pfilt -1 -x /2 -y /2 > $td/slab.pic
202 < pcomb $pc0args $pc1args $picture $cpict \
203 <        | pcompos $td/scol.pic 0 0 -t .2 $td/slab.pic 25 0 - $legwidth 0
199 >                -e "$imap" | sed -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/' ) \
200 >        | psign -s -.15 -cf 1 1 1 -cb 0 0 0 \
201 >                -h `ev "floor($legheight/$ndivs+.5)"` > $td/slab.pic
202 > else
203 >        set legwidth=0
204 >        set legheight=0
205 >        (echo "" ; echo "-Y 1 +X 1" ; echo "aaa" ) > $td/scol.pic
206 >        cp $td/scol.pic $td/slab.pic
207 > endif
208 > if ( $?doextrem ) then
209 >        pextrem -o $picture > $td/extrema
210 >        set minpos=`sed 2d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
211 >        set minval=`rcalc -e '$1=($3*.27+$4*.67+$5*.06)*'"$mult" $td/extrema | sed -e 2d -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/'`
212 >        set maxpos=`sed 1d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
213 >        set maxval=`rcalc -e '$1=($3*.27+$4*.67+$5*.06)*'"$mult" $td/extrema | sed -e 1d -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/'`
214 >        psign -s -.15 -a 2 -h 16 $minval > $td/minv.pic
215 >        psign -s -.15 -a 2 -h 16 $maxval > $td/maxv.pic
216 >        pcomb $pc0args $pc1args $picture $cpict \
217 >                | pcompos $td/scol.pic 0 0 \
218 >                        +t .1 "\!pcomb -e 'lo=1-gi(1)' $td/slab.pic" \
219 >                        `ev 2 $loff-1` -t .5 $td/slab.pic 0 $loff \
220 >                  - $legwidth 0 $td/minv.pic $minpos $td/maxv.pic $maxpos
221 > else
222 >        pcomb $pc0args $pc1args $picture $cpict \
223 >                | pcompos $td/scol.pic 0 0 \
224 >                        +t .1 "\!pcomb -e 'lo=1-gi(1)' $td/slab.pic" \
225 >                        `ev 2 $loff-1` -t .5 $td/slab.pic 0 $loff \
226 >                        - $legwidth 0
227 > endif
228   quit:
229   rm -rf $td

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines