95 |
|
my $td = tempdir( CLEANUP => 1 ); |
96 |
|
|
97 |
|
if ($needfile == 1 && $picture eq '-') { |
98 |
< |
$picture = $td . '/' . $picture; |
98 |
> |
# Pretend that $td/stdin.rad is the actual filename. |
99 |
> |
$picture = "$td/stdin.hdr"; |
100 |
|
open(FHpic, ">$picture") or |
101 |
|
die("Unable to write to file $picture\n"); |
102 |
+ |
# Input is from STDIN: Capture to file. |
103 |
+ |
while (<>) { |
104 |
+ |
print FHpic; |
105 |
+ |
} |
106 |
|
close(FHpic); |
107 |
+ |
|
108 |
+ |
if ($cpict eq '-') { |
109 |
+ |
$cpict = "$td/stdin.hdr"; |
110 |
+ |
} |
111 |
|
} |
112 |
|
|
113 |
|
# Find a good scale for auto mode. |
114 |
|
if ($scale =~ m/[aA].*/) { |
115 |
< |
my $LogLmax = `phisto $picture| tail -2| sed -n '1s/[0-9]*\$//p'`; |
115 |
> |
my @histo = split(/\s/, `phisto $picture| tail -2`); |
116 |
> |
# e.g. $ phisto tests/richmond.hdr| tail -2 |
117 |
> |
# 3.91267 14 |
118 |
> |
# 3.94282 6 |
119 |
> |
my $LogLmax = $histo[0]; |
120 |
|
$scale = $mult / 179 * 10**$LogLmax; |
121 |
|
} |
122 |
|
|
123 |
< |
my $pc0 = $td . '/pc0.cal'; |
123 |
> |
my $pc0 = "$td/pc0.cal"; |
124 |
|
open(FHpc0, ">$pc0"); |
125 |
|
print FHpc0 <<EndOfPC0; |
126 |
|
PI : 3.14159265358979323846 ; |
187 |
|
bo = if(in,clip($bluv),ba); |
188 |
|
EndOfPC0 |
189 |
|
|
190 |
< |
my $pc1 = $td . '/pc1.cal'; |
190 |
> |
my $pc1 = "$td/pc1.cal"; |
191 |
|
open(FHpc1, ">$pc1"); |
192 |
|
print FHpc1 <<EndOfPC1; |
193 |
|
norm : mult/scale/le(1); |
226 |
|
} |
227 |
|
|
228 |
|
# Colours in the legend |
229 |
< |
my $scolpic = $td . '/scol.hdr'; |
229 |
> |
my $scolpic = "$td/scol.hdr"; |
230 |
|
# Labels in the legend |
231 |
< |
my $slabpic = $td . '/slab.hdr'; |
231 |
> |
my $slabpic = "$td/slab.hdr"; |
232 |
|
my $cmd; |
233 |
|
|
234 |
< |
if ($legwidth > 20 && $legheight > 40) { |
234 |
> |
if (($legwidth > 20) && ($legheight > 40)) { |
235 |
|
# Legend: Create the background colours |
236 |
|
$cmd = "pcomb $pc0args -e 'v=(y+.5)/yres;vleft=v;vright=v'"; |
237 |
|
$cmd .= " -e 'vbelow=(y-.5)/yres;vabove=(y+1.5)/yres'"; |
241 |
|
# Legend: Create the text labels |
242 |
|
my $sheight = floor($legheight / $ndivs + 0.5); |
243 |
|
my $text = "$label"; |
244 |
< |
my $value; |
232 |
< |
my $i; |
233 |
< |
for ($i=0; $i<$ndivs; $i++) { |
244 |
> |
for (my $i=0; $i<$ndivs; $i++) { |
245 |
|
my $imap = ($ndivs - 0.5 - $i) / $ndivs; |
246 |
+ |
my $value = $scale; |
247 |
|
if ($decades > 0) { |
248 |
< |
$value = $scale * 10**(($imap - 1) * $decades); |
248 |
> |
$value *= 10**(($imap - 1) * $decades); |
249 |
|
} else { |
250 |
< |
$value = $scale * $imap; |
250 |
> |
$value *= $imap; |
251 |
|
} |
252 |
|
# Have no more than 3 decimal places |
253 |
|
$value =~ s/(\.[0-9]{3})[0-9]*/$1/; |
260 |
|
# Legend is too small to be legible. Don't bother doing one. |
261 |
|
$legwidth = 0; |
262 |
|
$legheight = 0; |
263 |
+ |
# Create dummy colour scale and legend labels so we don't |
264 |
+ |
# need to change the final command line. |
265 |
|
open(FHscolpic, ">$scolpic"); |
266 |
|
print FHscolpic "\n-Y 1 +X 1\naaa\n"; |
267 |
|
close(FHscolpic); |
270 |
|
close(FHslabpic); |
271 |
|
} |
272 |
|
|
273 |
+ |
# Legend: Invert the text labels (for dropshadow) |
274 |
+ |
my $slabinvpic = "$td/slabinv.hdr"; |
275 |
+ |
$cmd = "pcomb -e 'lo=1-gi(1)' $slabpic > $slabinvpic"; |
276 |
+ |
system $cmd; |
277 |
+ |
|
278 |
|
my $loff1 = $loff - 1; |
279 |
|
# Command line without extrema |
280 |
|
$cmd = "pcomb $pc0args $pc1args $picture $cpict"; |
281 |
< |
$cmd .= "| pcompos $scolpic 0 0 +t .1"; |
263 |
< |
$cmd .= " \"\!pcomb -e 'lo=1-gi(1)' $slabpic\" 2 $loff1"; |
281 |
> |
$cmd .= "| pcompos $scolpic 0 0 +t .1 $slabinvpic 2 $loff1"; |
282 |
|
$cmd .= " -t .5 $slabpic 0 $loff - $legwidth 0"; |
283 |
|
|
284 |
|
if ($doextrem == 1) { |
291 |
|
# 211 202 1.292969e+00 1.308594e+00 1.300781e+00 |
292 |
|
|
293 |
|
my @extrema = split(/\s/, $retval); |
294 |
< |
my $lxmin = $extrema[0] + $legwidth; |
295 |
< |
my $ymin = $extrema[1]; |
296 |
< |
my $rmin = $extrema[2]; |
279 |
< |
my $gmin = $extrema[3]; |
280 |
< |
my $bmin = $extrema[4]; |
281 |
< |
my $lxmax = $extrema[5] + $legwidth; |
282 |
< |
my $ymax = $extrema[6]; |
283 |
< |
my $rmax = $extrema[7]; |
284 |
< |
my $gmax = $extrema[8]; |
285 |
< |
my $bmax = $extrema[9]; |
294 |
> |
my ($lxmin, $ymin, $rmin, $gmin, $bmin, $lxmax, $ymax, $rmax, $gmax, $bmax) = @extrema; |
295 |
> |
$lxmin += $legwidth; |
296 |
> |
$lxmax += $legwidth; |
297 |
|
|
298 |
|
# Weighted average of R,G,B |
299 |
|
my $minpos = "$lxmin $ymin"; |
304 |
|
$maxval =~ s/(\.[0-9]{3})[0-9]*/$1/; |
305 |
|
|
306 |
|
# Create the labels for min/max intensity |
307 |
< |
my $minvpic = $td . '/minv.hdr'; |
307 |
> |
my $minvpic = "$td/minv.hdr"; |
308 |
|
$cmd1 = "psign -s -.15 -a 2 -h 16 $minval > $minvpic"; |
309 |
|
system $cmd1; |
310 |
< |
my $maxvpic = $td . '/maxv.hdr'; |
310 |
> |
my $maxvpic = "$td/maxv.hdr"; |
311 |
|
$cmd1 = "psign -s -.15 -a 2 -h 16 $maxval > $maxvpic"; |
312 |
|
system $cmd1; |
313 |
|
|