#! /bin/bash # Last edited on 2008-02-04 20:31:56 by stolfi usage="${0##*/} NAME NX NY" # Reads # # "NAME-s.jpg" the small (1/4 size) version of an image, # "NAME.grmap" the (H,V) <-> (X,Y) projective matrices, # "NAME.grpts" the reference points of the image, # # Writes an image "NAME-g.jpg" showing the reference points and the # grid (assumed to be NX by NY cm). Computes the matrix "NAME.grmap" # if it is missing. # if [ $# -ne 3 ]; then echo "usage: ${usage}"; exit 1; fi name="$1"; shift; nx="$1"; shift; ny="$1"; shift; batroot="${STOLFIHOME}/projects/fragments/IAB-2002/raw-sorted" tools="${STOLFIHOME}/projects/fragments/IAB-2002/tools" ( cd ${batroot}/. ) img="${batroot}/${name}-s.jpg" if [ ! -r ${img} ]; then echo "no image ${img}"; exit 1 fi grpts="${batroot}/${name}.grpts" if [ ! -r ${grpts} ]; then echo "no gridpoints file ${grpts}"; exit 1 fi map="${batroot}/${name}.grmap" ${tools}/compute-grid-map -f ${tools}/r3x3.gawk -v check=0 < ${grpts} > ${map} out="${batroot}/${name}-g.jpg" gcmds="${batroot}/${name}.gcmds" pcmds="${batroot}/${name}.pcmds" ${tools}/draw-grid -f ${tools}/r3x3.gawk \ -v scale=0.25 \ -v nx=${nx} -v ny=${ny} < ${map} > ${gcmds} if [ ! -e ${gcmds} ]; then echo "file ${gcmds} not created"; exit 1; fi; ${tools}/draw-gridpoints \ -v scale=0.25 \ < ${grpts} > ${pcmds} if [ ! -e ${pcmds} ]; then echo "file ${pcmds} not created"; exit 1; fi; convert \ -font '-*-courier-medium-r-*-*-10-*-*-*-*-*-iso8859-*' \ -fill yellow -draw "@${gcmds}" \ -fill red -draw "@${pcmds}" \ ${img} ${out} if [ ! -e ${out} ]; then echo "image ${out} doesnt exist"; exit 1; fi; # display ${out} /bin/rm -f ${pcmds} ${gcmds}