ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/falsecolor.csh
Revision: 2.15
Committed: Fri Nov 18 22:50:21 2005 UTC (18 years, 5 months ago) by greg
Content type: application/x-csh
Branch: MAIN
CVS Tags: rad3R8
Changes since 2.14: +13 -13 lines
Log Message:
Made false color scale less bloody than before

File Contents

# Content
1 #!/bin/csh -fe
2 # RCSid: $Id: falsecolor.csh,v 2.14 2005/11/18 22:17:16 greg Exp $
3 #
4 # Create false color image with legend
5 #
6 # Added user-definable legend 2004/01/20 Rob Guglielmetti
7
8 set td=/tmp/fc$$
9 onintr quit
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'
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]"
39 breaksw
40 case -s:
41 shift argv
42 set scale="$argv[1]"
43 breaksw
44 case -l:
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]"
55 breaksw
56 case -g:
57 shift argv
58 set grnv="$argv[1]"
59 breaksw
60 case -b:
61 shift argv
62 set bluv="$argv[1]"
63 breaksw
64 case -i:
65 shift argv
66 set picture="$argv[1]"
67 breaksw
68 case -p:
69 shift argv
70 set cpict="$argv[1]"
71 breaksw
72 case -ip:
73 case -pi:
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 shift argv
92 set ndivs="$argv[1]"
93 breaksw
94 default:
95 echo bad option "'$argv[1]'"
96 exit 1
97 endsw
98 shift argv
99 end
100 mkdir $td
101 cat > $td/pc0.cal <<_EOF_
102 PI : 3.14159265358979323846 ;
103 scale : $scale ;
104 mult : $mult ;
105 ndivs : $ndivs ;
106
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,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+.5),floor(ndivs*b+.5));
114
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 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);
158
159 map(x) = x;
160
161 ra = ri(nfiles);
162 ga = gi(nfiles);
163 ba = bi(nfiles);
164 _EOF_
165 set pc0args=(-f $td/pc0.cal)
166 set pc1args=(-f $td/pc1.cal)
167 if ($?docont) then
168 set pc0args=($pc0args -e "in=iscont$docont")
169 endif
170 if ("$cpict" == "") then
171 set pc1args=($pc1args -e 'ra=0;ga=0;ba=0')
172 else if ("$cpict" == "$picture") then
173 set cpict=
174 endif
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 $td