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

Comparing ray/src/px/falsecolor.pl (file contents):
Revision 2.5 by greg, Wed Oct 26 03:42:49 2011 UTC vs.
Revision 2.6 by greg, Wed Jan 18 00:30:35 2012 UTC

# Line 21 | Line 21 | my $picture = '-';
21   my $cpict = '';
22   my $legwidth = 100;            # Legend width and height
23   my $legheight = 200;
24 < my $docont = '';               # Contours
24 > my $docont = '';               # Contours: -cl and -cb
25 > my $doposter = 0;              # Posterization: -cp
26   my $loff = 0;                  # Offset to align with values
27   my $doextrem = 0;              # Don't mark extrema
28   my $needfile = 0;
29 + my $showpal = 0;               # Show availabel colour palettes
30  
31   while ($#ARGV >= 0) {
32      $_ = shift;
# Line 75 | Line 77 | while ($#ARGV >= 0) {
77      } elsif (m/-cb/) {         # Contour bands
78          $docont = 'b';
79          $loff = 0.52;
80 +    } elsif (m/-cp/) {              # Posterize
81 +        $doposter = 1;
82 +    } elsif (m/-palettes/) {        # Show all available palettes
83 +        $scale   = 45824;           # 256 * 179
84 +        $showpal = 1;
85      } elsif (m/-e/) {
86          $doextrem = 1;
87          $needfile = 1;
# Line 100 | Line 107 | if ($needfile == 1 && $picture eq '-') {
107      close(FHpic);
108  
109      if ($cpict eq '-') {
110 <        $cpict =  "$td/stdin.hdr";
110 >        $cpict = "$td/stdin.hdr";
111      }
112   }
113  
# Line 137 | Line 144 | spec_blu(x) = 1 - 8/3*x;
144  
145   pm3d_red(x) = sqrt(x) ^ gamma;
146   pm3d_grn(x) = (x*x*x) ^ gamma;
147 < pm3d_blu(x) = clip(sin(2*PI*x)) ^ gamma;
147 > pm3d_blu(x) = clip(sin(2*PI*clip(x))) ^ gamma;
148  
149   hot_red(x) = clip(3*x) ^ gamma;
150   hot_grn(x) = clip(3*x - 1) ^ gamma;
# Line 180 | Line 187 | ro = if(in,clip($redv),ra);
187   go = if(in,clip($grnv),ga);
188   bo = if(in,clip($bluv),ba);
189   EndOfPC0
190 + close FHpc0;
191  
192   my $pc1 = "$td/pc1.cal";
193   open(FHpc1, ">$pc1");
# Line 199 | Line 207 | ra = ri(nfiles);
207   ga = gi(nfiles);
208   ba = bi(nfiles);
209   EndOfPC1
210 + close FHpc1;
211  
212   my $pc0args = "-f $pc0";
213   my $pc1args = "-f $pc1";
214  
215 < # Contour lines or bands
215 > if ($showpal == 1) {
216 >    my $pc = "pcompos -a 1";
217 >    foreach my $pal (@palettes) {
218 >        my $fcimg = "$td/$pal.hdr";
219 >        my $lbimg = "$td/${pal}_label.hdr";
220 >        system "psign -cb 0 0 0 -cf 1 1 1 -h 20 $pal > $lbimg";
221 >
222 >        my $cmd = qq[pcomb $pc0args -e "v=x/256"];
223 >        $cmd .= qq[ -e "ro=clip(${pal}_red(v));go=clip(${pal}_grn(v));bo=clip(${pal}_blu(v))"];
224 >        $cmd .= qq[ -x 256 -y 30 > $fcimg];
225 >        system "$cmd";
226 >        $pc .= " $fcimg $lbimg";
227 >    }
228 >    system "$pc";
229 >    exit 0;
230 > }
231 >
232 > # Contours
233   if ($docont ne '') {
234 <    $pc0args .= " -e 'in=iscont$docont'";
234 >    # -cl -> $docont = a
235 >    # -cb -> $docont = b
236 >    $pc0args .= qq[ -e "in=iscont$docont"];
237 > } elsif ($doposter == 1) {
238 >    # -cp -> $doposter = 1
239 >    $pc0args .= qq[ -e "ro=${pal}_red(seg(v));go=${pal}_grn(seg(v));bo=${pal}_blu(seg(v))"];
240 >    $pc0args .= q[ -e "seg(x)=(floor(v*ndivs)+.5)/ndivs"];
241   }
242  
243   if ($cpict eq '') {
244 <    $pc1args .= " -e 'ra=0;ga=0;ba=0'";
244 >    $pc1args .= qq[ -e "ra=0;ga=0;ba=0"];
245   } elsif ($cpict eq $picture) {
246      $cpict = '';
247   }
248  
249   # Logarithmic mapping
250   if ($decades > 0) {
251 <    $pc1args .= " -e 'map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)'";
251 >    $pc1args .= qq[ -e "map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)"];
252   }
253  
254   # Colours in the legend
255   my $scolpic = "$td/scol.hdr";
256 +
257   # Labels in the legend
258   my $slabpic = "$td/slab.hdr";
259   my $cmd;
# Line 239 | Line 272 | if (($legwidth > 20) && ($legheight > 40)) {
272          } else {
273              $value *= $imap;
274          }
275 +
276          # Have no more than 3 decimal places
277          $value =~ s/(\.[0-9]{3})[0-9]*/$1/;
278          $text .= "\n$value";
279      }
280 <    $cmd = "echo '$text' | psign -s -.15 -cf 1 1 1 -cb 0 0 0";
281 <    $cmd .= " -h $sheight > $slabpic";
282 <    system $cmd;
280 >    open PSIGN, "| psign -s -.15 -cf 1 1 1 -cb 0 0 0 -h $sheight > $slabpic";
281 >    print PSIGN "$text";
282 >    close PSIGN;
283  
284      # Legend: Create the background colours
285 <    $cmd = "pcomb $pc0args -e 'v=(y+.5)/yres;vleft=v;vright=v'";
286 <    $cmd .= " -e 'vbelow=(y-.5)/yres;vabove=(y+1.5)/yres'";
287 <    $cmd .= " -x $legwidth -y $legheight > $scolpic";
285 >    $cmd = qq[pcomb $pc0args];
286 >    $cmd .= q[ -e "v=(y+.5)/yres;vleft=v;vright=v"];
287 >    $cmd .= q[ -e "vbelow=(y-.5)/yres;vabove=(y+1.5)/yres"];
288 >    $cmd .= qq[ -x $legwidth -y $legheight > $scolpic];
289      system $cmd;
290   } else {
291      # Legend is too small to be legible. Don't bother doing one.
292      $legwidth = 0;
293      $legheight = 0;
294      $loff = 0;
295 +
296      # Create dummy colour scale and legend labels so we don't
297      # need to change the final command line.
298      open(FHscolpic, ">$scolpic");
# Line 269 | Line 305 | if (($legwidth > 20) && ($legheight > 40)) {
305  
306   # Legend: Invert the text labels (for dropshadow)
307   my $slabinvpic = "$td/slabinv.hdr";
308 < $cmd = "pcomb -e 'lo=1-gi(1)' $slabpic > $slabinvpic";
308 > $cmd = qq[pcomb -e "lo=1-gi(1)" $slabpic > $slabinvpic];
309   system $cmd;
310  
311   my $loff1 = $loff - 1;
312 +
313   # Command line without extrema
314 < $cmd = "pcomb $pc0args $pc1args $picture $cpict";
315 < $cmd .= "| pcompos $scolpic 0 0 +t .1 $slabinvpic 2 $loff1";
316 < $cmd .= " -t .5 $slabpic 0 $loff - $legwidth 0";
314 > $cmd = qq[pcomb $pc0args $pc1args $picture $cpict];
315 > $cmd .= qq[ | pcompos $scolpic 0 0 +t .1 $slabinvpic 2 $loff1];
316 > $cmd .= qq[ -t .5 $slabpic 0 $loff - $legwidth 0];
317  
318   if ($doextrem == 1) {
319      # Get min/max image luminance
# Line 296 | Line 333 | if ($doextrem == 1) {
333      my $minpos = "$lxmin $ymin";
334      my $minval = ($rmin * .27 + $gmin * .67 + $bmin * .06) * $mult;
335      $minval =~ s/(\.[0-9]{3})[0-9]*/$1/;
299    my $maxpos = "$lxmax $ymax";
336      my $maxval = ($rmax * .27 + $gmax * .67 + $bmax * .06) * $mult;
337      $maxval =~ s/(\.[0-9]{3})[0-9]*/$1/;
338  
339      # Create the labels for min/max intensity
340      my $minvpic = "$td/minv.hdr";
341 <    $cmd1 = "psign -s -.15 -a 2 -h 16 $minval > $minvpic";
306 <    system $cmd1;
341 >    system "psign -s -.15 -a 2 -h 16 $minval > $minvpic";
342      my $maxvpic = "$td/maxv.hdr";
343 <    $cmd1 = "psign -s -.15 -a 2 -h 16 $maxval > $maxvpic";
309 <    system $cmd1;
343 >    system "psign -s -.15 -a 2 -h 16 $maxval > $maxvpic";
344  
345      # Add extrema labels to command line
346 <    $cmd .= " $minvpic $minpos $maxvpic $maxpos";
346 >    $cmd .= qq[ $minvpic $minpos $maxvpic $lxmax $ymax];
347   }
348  
349   # Process image and combine with legend

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines