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.1 by greg, Thu May 23 13:45:18 1991 UTC vs.
Revision 2.15 by greg, Fri Nov 18 22:50:21 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 redv='2*v-1'
14 < set grnv='if(v-.5,2-2*v,2*v)'
15 < set bluv='1-2*v'
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'
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 28 | Line 45 | while ($#argv > 0)
45                  shift argv
46                  set label="$argv[1]"
47                  breaksw
48 +        case -log:
49 +                shift argv
50 +                set decades=$argv[1]
51 +                breaksw
52          case -r:
53                  shift argv
54                  set redv="$argv[1]"
# Line 50 | Line 71 | while ($#argv > 0)
71                  breaksw
72          case -ip:
73          case -pi:
74 <                shiftargv
74 >                shift argv
75                  set picture="$argv[1]"
76                  set cpict="$argv[1]"
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 <                shiftargv
91 >                shift argv
92                  set ndivs="$argv[1]"
93 <                breadsw
93 >                breaksw
94          default:
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 ;
# Line 79 | Line 107 | ndivs : $ndivs ;
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 < red=$redv;
116 < grn=$grnv;
117 < 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.001367254,
119 > 0.003076,0.01376382,0.06170773,0.1739422,0.2881156,0.3299725,
120 > 0.3552663,0.372552,0.3921184,0.4363976,0.6102754,0.7757267,
121 > 0.9087369,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.4247083,0.4739468,
125 > 0.4402732,0.3671876,0.2629843,0.1725325,0.1206819,0.07316644,
126 > 0.03761026,0.01612362,0.004773749,6.830967e-06,0.00803605,
127 > 0.1008085,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.4085123,0.1702815,0.05314236,
131 > 0.05194055,0.08564082,0.09881395,0.08324373,0.06072902,
132 > 0.0391076,0.02315354,0.01284458,0.005184709,0.001691774,
133 > 2.432735e-05,1.212949e-05,0.006659406,0.02539);
134 > def_blu(x):interp_arr(x/0.0454545+1,def_blup);
135  
136 < v = li(1)*(mult/scale);
137 < vleft = li(1,-1,0)*(mult/scale);
92 < vright = li(1,1,0)*(mult/scale);
93 < vabove = li(1,0,1)*(mult/scale);
94 < vbelow = li(1,0,-1)*(mult/scale);
95 < isconta = or(boundary(vleft,vright),boundary(vabove,vbelow));
96 < iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),0);
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 < ro = if(in,red,ra);
140 < go = if(in,grn,ga);
141 < bo = if(in,blu,ba);
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);
158 +
159 + map(x) = x;
160 +
161   ra = ri(nfiles);
162   ga = gi(nfiles);
163   ba = bi(nfiles);
105
106 in = 1;
164   _EOF_
165 < set pcargs=(-o -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 < pcomb $pcargs -e 'v=(y+.5)/200;vleft=v;vright=v' \
176 <                -e 'vbelow=(y-.5)/200;vabove=(y+1.5)/200' \
177 <                -e 'ra=0;ga=0;ba=0' -x 100 -y 200 \
178 <                > $tempdir/scol.pic
179 < (echo $label; cnt $ndivs |rcalc -e '$1='"($scale)/$ndivs*($ndivs"'-.5-$1)') \
180 <        | psign -cf 1 1 1 -cb 0 0 0 -h `ev "floor(200/$ndivs+.5)"` \
181 <                > $tempdir/slab.pic
182 < pcomb $pcargs $picture $cpict \
183 <        | pcompos $tempdir/scol.pic 0 0 -t .5 $tempdir/slab.pic 25 0 - 100 0
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 > 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" | 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