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.4 by greg, Fri May 24 17:23:01 1991 UTC vs.
Revision 2.14 by greg, Fri Nov 18 22:17:16 2005 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 tempdir=/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='2*v-1'
15 < set grnv='if(v-.5,2-2*v,2*v)'
16 < set bluv='1-2*v'
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'
17 > set redv='def_red(v)'
18 > set grnv='def_grn(v)'
19 > set bluv='def_blu(v)'
20   set ndivs=8
21   set picture='-'
22   set cpict=
23 + set loff=0
24 + set legwidth=100
25 + set legheight=200
26   while ($#argv > 0)
27          switch ($argv[1])
28 +        case -lw:
29 +                shift argv
30 +                set legwidth="$argv[1]"
31 +                breaksw
32 +        case -lh:
33 +                shift argv
34 +                set legheight="$argv[1]"
35 +                breaksw
36          case -m:
37                  shift argv
38                  set mult="$argv[1]"
# Line 61 | Line 77 | while ($#argv > 0)
77                  breaksw
78          case -cl:
79                  set docont=a
80 +                set loff=12
81                  breaksw
82          case -cb:
83                  set docont=b
84 +                set loff=13
85                  breaksw
86 +        case -e:
87 +                set doextrem
88 +                set needfile
89 +                breaksw
90          case -n:
91                  shift argv
92                  set ndivs="$argv[1]"
93                  breaksw
94          default:
95 <                echo bad option "'$argv[1]'" >/dev/tty
95 >                echo bad option "'$argv[1]'"
96                  exit 1
97          endsw
98          shift argv
99   end
100 < mkdir $tempdir
101 < cat > $tempdir/pc.cal <<_EOF_
100 > mkdir $td
101 > cat > $td/pc0.cal <<_EOF_
102 > PI : 3.14159265358979323846 ;
103   scale : $scale ;
104   mult : $mult ;
105   ndivs : $ndivs ;
106  
84 norm : if(nfiles-.5, mult/scale/le(1), 0);
85
107   or(a,b) : if(a,a,b);
108   EPS : 1e-7;
109   neq(a,b) : if(a-b-EPS,1,b-a-EPS);
110 < btwn(a,b) : if(a-x,-1,b-x);
110 > btwn(a,x,b) : if(a-x,-1,b-x);
111 > clip(x) : if(x-1,1,if(x,x,0));
112   frac(x) : x - floor(x);
113 < boundary(a,b) : neq(floor(ndivs*a),floor(ndivs*b));
113 > boundary(a,b) : neq(floor(ndivs*a+.5),floor(ndivs*b+.5));
114  
115 < map(x) = x;
116 < red = $redv;
117 < grn = $grnv;
118 < blu = $bluv;
115 > interp_arr2(i,x,f):(i+1-x)*f(i)+(x-i)*f(i+1);
116 > interp_arr(x,f):if(x-1,if(f(0)-x,interp_arr2(floor(x),x,f),f(f(0))),f(1));
117 > def_redp(i):select(i,0.18848,0.05468174,
118 > 0.00103547,8.311144e-08,7.449763e-06,0.0004390987,0.001389302,
119 > 0.003306035,0.01381413,0.0563861,0.1534137,0.2581243,0.3059902,
120 > 0.3449827,0.3791056,0.4138921,0.4678283,0.624231,0.7732902,
121 > 0.9067587,1,1,0.9863);
122 > def_red(x):interp_arr(x/0.0454545+1,def_redp);
123 > def_grnp(i):select(i,0.0009766,2.35501e-05,
124 > 0.0008966244,0.0264977,0.1256843,0.2865799,0.424867,0.4750973,
125 > 0.4403898,0.3568169,0.244569,0.1643434,0.1297663,0.1001566,
126 > 0.07522873,0.05465921,0.03394894,0.001412969,0.00681687,
127 > 0.0974651,0.3106831,0.6447838,0.9707);
128 > def_grn(x):interp_arr(x/0.0454545+1,def_grnp);
129 > def_blup(i):select(i,0.2666,0.3638662,0.4770437,
130 > 0.5131397,0.5363797,0.5193677,0.4091852,0.1732726,0.05331749,
131 > 0.04184916,0.05768565,0.070331,0.0738812,0.07805368,0.08024318,
132 > 0.07775604,0.06449649,0.01028498,0.0003090336,0.0004275006,
133 > 0.002297005,0.01128842,0.02539);
134 > def_blu(x):interp_arr(x/0.0454545+1,def_blup);
135  
136 + isconta = if(btwn(0,v,1),or(boundary(vleft,vright),boundary(vabove,vbelow)),-1);
137 + iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),-1);
138 +
139 + ra = 0;
140 + ga = 0;
141 + ba = 0;
142 +
143 + in = 1;
144 +
145 + ro = if(in,clip($redv),ra);
146 + go = if(in,clip($grnv),ga);
147 + bo = if(in,clip($bluv),ba);
148 + _EOF_
149 + cat > $td/pc1.cal <<_EOF_
150 + norm : mult/scale/le(1);
151 +
152   v = map(li(1)*norm);
153 +
154   vleft = map(li(1,-1,0)*norm);
155   vright = map(li(1,1,0)*norm);
156   vabove = map(li(1,0,1)*norm);
157   vbelow = map(li(1,0,-1)*norm);
103 isconta = or(boundary(vleft,vright),boundary(vabove,vbelow));
104 iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),0);
158  
159 < ro = if(in,red,ra);
107 < go = if(in,grn,ga);
108 < bo = if(in,blu,ba);
159 > map(x) = x;
160  
161   ra = ri(nfiles);
162   ga = gi(nfiles);
163   ba = bi(nfiles);
113
114 in = 1;
164   _EOF_
165 < set pcargs=(-f $tempdir/pc.cal)
165 > set pc0args=(-f $td/pc0.cal)
166 > set pc1args=(-f $td/pc1.cal)
167   if ($?docont) then
168 <        set pcargs=($pcargs -e "in=iscont$docont")
168 >        set pc0args=($pc0args -e "in=iscont$docont")
169   endif
170   if ("$cpict" == "") then
171 <        set pcargs=($pcargs -e 'ra=0;ga=0;ba=0')
171 >        set pc1args=($pc1args -e 'ra=0;ga=0;ba=0')
172   else if ("$cpict" == "$picture") then
173          set cpict=
174   endif
175 < if ($decades > 0) then
176 <        set pcargs=($pcargs -e "map(x)=log10(x)/$decades+1")
175 > if ($?needfile && "$picture" == '-') then
176 >        cat > $td/picture
177 >        set picture=$td/picture
178 > endif
179 > if ("$decades" != "0") then
180 >        set pc1args=($pc1args -e "map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)")
181          set imap="imap(y)=10^((y-1)*$decades)"
182   else
183          set imap="imap(y)=y"
184   endif
185 < pcomb $pcargs -e 'v=(y+.5)/200;vleft=v;vright=v' \
186 <                -e 'vbelow=(y-.5)/200;vabove=(y+1.5)/200' \
187 <                -e 'ra=0;ga=0;ba=0' -x 100 -y 200 \
188 <                > $tempdir/scol.pic
189 < ( echo $label; cnt $ndivs \
185 > if ( $legwidth > 20 && $legheight > 40 ) then
186 > pcomb $pc0args -e 'v=(y+.5)/yres;vleft=v;vright=v' \
187 >                -e 'vbelow=(y-.5)/yres;vabove=(y+1.5)/yres' \
188 >                -x $legwidth -y $legheight > $td/scol.pic
189 > ( echo "$label"; cnt $ndivs \
190                  | rcalc -e '$1='"($scale)*imap(($ndivs-.5-"'$1'")/$ndivs)" \
191 <                -e "$imap" ) \
192 <        | psign -cf 1 1 1 -cb 0 0 0 -h `ev "floor(2*200/$ndivs+.5)"` \
193 <        | pfilt -1 -x /2 -y /2 > $tempdir/slab.pic
194 < pcomb $pcargs $picture $cpict \
195 <        | pcompos $tempdir/scol.pic 0 0 -t .2 $tempdir/slab.pic 25 0 - 100 0
191 >                -e "$imap" | sed -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/' ) \
192 >        | psign -s -.15 -cf 1 1 1 -cb 0 0 0 \
193 >                -h `ev "floor($legheight/$ndivs+.5)"` > $td/slab.pic
194 > else
195 >        set legwidth=0
196 >        set legheight=0
197 >        (echo "" ; echo "-Y 1 +X 1" ; echo "aaa" ) > $td/scol.pic
198 >        cp $td/scol.pic $td/slab.pic
199 > endif
200 > if ( $?doextrem ) then
201 >        pextrem -o $picture > $td/extrema
202 >        set minpos=`sed 2d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
203 >        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/'`
204 >        set maxpos=`sed 1d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
205 >        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/'`
206 >        psign -s -.15 -a 2 -h 16 $minval > $td/minv.pic
207 >        psign -s -.15 -a 2 -h 16 $maxval > $td/maxv.pic
208 >        pcomb $pc0args $pc1args $picture $cpict \
209 >                | pcompos $td/scol.pic 0 0 \
210 >                        +t .1 "\!pcomb -e 'lo=1-gi(1)' $td/slab.pic" \
211 >                        `ev 2 $loff-1` -t .5 $td/slab.pic 0 $loff \
212 >                  - $legwidth 0 $td/minv.pic $minpos $td/maxv.pic $maxpos
213 > else
214 >        pcomb $pc0args $pc1args $picture $cpict \
215 >                | pcompos $td/scol.pic 0 0 \
216 >                        +t .1 "\!pcomb -e 'lo=1-gi(1)' $td/slab.pic" \
217 >                        `ev 2 $loff-1` -t .5 $td/slab.pic 0 $loff \
218 >                        - $legwidth 0
219 > endif
220   quit:
221 < rm -rf $tempdir
221 > rm -rf $td

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines