1 |
#!/bin/csh -f |
2 |
# RCSid $Id: ra_pfm.csh,v 2.2 2004/12/25 04:14:25 greg Exp $ |
3 |
# |
4 |
# Convert to/from Poskanzer Float Map image format using pvalue |
5 |
# |
6 |
if (`uname -p` == powerpc) then |
7 |
set machend=big |
8 |
else |
9 |
set machend=little |
10 |
endif |
11 |
while ($#argv > 0) |
12 |
if ("$argv[1]" == "-r") then |
13 |
set reverse |
14 |
else if (! $?inp) then |
15 |
set inp="$argv[1]" |
16 |
else if (! $?out) then |
17 |
set out="$argv[1]" |
18 |
else |
19 |
goto userr |
20 |
endif |
21 |
shift argv |
22 |
end |
23 |
if ($?reverse) then |
24 |
if (! $?inp) then |
25 |
goto userr |
26 |
endif |
27 |
set opt="" |
28 |
set hl="`head -3 $inp:q`" |
29 |
if ("$hl[1]" == "Pf") then |
30 |
set opt=($opt -b) |
31 |
else if ("$hl[1]" != "PF") then |
32 |
echo "Input not a Poskanzer Float Map" |
33 |
exit 1 |
34 |
endif |
35 |
if (`ev "if($hl[3],1,0)"`) then |
36 |
set filend=big |
37 |
else |
38 |
set filend=little |
39 |
endif |
40 |
if ($filend != $machend) then |
41 |
set opt=($opt -dF) |
42 |
else |
43 |
set opt=($opt -df) |
44 |
endif |
45 |
set res=($hl[2]) |
46 |
if ($?out) then |
47 |
tail +4 $inp:q | pvalue -r -h $opt -y $res[2] +x $res[1] > $out:q |
48 |
else |
49 |
tail +4 $inp:q | pvalue -r -h $opt -y $res[2] +x $res[1] |
50 |
endif |
51 |
exit $status |
52 |
endif |
53 |
if (! $?inp) then |
54 |
goto userr |
55 |
endif |
56 |
set res=(`getinfo -d < $inp:q`) |
57 |
if ($?out) then |
58 |
( echo PF ; echo $res[4] $res[2] ) > $out:q |
59 |
if ($machend == little) then |
60 |
echo "-1.000000" >> $out:q |
61 |
else |
62 |
echo "1.000000" >> $out:q |
63 |
endif |
64 |
pvalue -h -H -df $inp:q >> $out:q |
65 |
else |
66 |
echo PF |
67 |
echo $res[4] $res[2] |
68 |
if ($machend == little) then |
69 |
echo "-1.000000" |
70 |
else |
71 |
echo "1.000000" |
72 |
endif |
73 |
pvalue -h -H -df $inp:q |
74 |
endif |
75 |
exit $status |
76 |
userr: |
77 |
echo "Usage: $0 input.pfm [output.hdr]" |
78 |
echo " or: $0 -r input.hdr [output.pfm]" |
79 |
exit 1 |