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