#!/bin/sh
#

if [ ! $1 ]
then
   echo "Usage:"
   echo "   $0 infile.ppm"
   echo ""
   echo "Will produce infile_hf.pgm, a heightfield"
fi

name=$1

if [ ! -f ${name} ]
then
   echo "Usage:"
   echo "   $0 infile.ppm"
   echo ""
   echo "Will produce infile_hf.pgm, a heightfield"
fi

name=`basename ${name} .ppm`

rgb2hsv ${name}.ppm > ${name}.hsv
ppmtorgb3 ${name}.hsv
pnminvert ${name}.red > ${name}_hf.pgm
rm ${name}.hsv ${name}.red ${name}.grn ${name}.blu

echo "done."

