#!/bin/sh if [ $# -ne 5 ] then echo "usage: scale_click.sh xmin xmax ymin ymax file" exit 1 fi # reference points in the final units from the command line XMIN=$1 XMAX=$2 YMIN=$3 YMAX=$4 FILE=$5 # reference points in pixels from the first 4 clicks XMINP=`sed -n '1p' $FILE | cut -f1` XMAXP=`sed -n '2p' $FILE | cut -f1` YMINP=`sed -n '3p' $FILE | cut -f2` YMAXP=`sed -n '4p' $FILE | cut -f2` echo "# Xp -> ($XMAX-$XMIN)/($XMAXP-$XMINP)*(Xp-$XMINP) + $XMIN" echo "# Yp -> ($YMAX-$YMIN)/($YMAXP-$YMINP)*(Yp-$YMINP) + $YMIN" awk "{if(NR > 4){print ($XMAX-$XMIN)/($XMAXP-$XMINP)*(\$1-$XMINP) + $XMIN, \ ($YMAX-$YMIN)/($YMAXP-$YMINP)*(\$2-$YMINP) + $YMIN}}" \ $FILE exit 0