#! /bin/gawk -f # Last edited on 2003-02-03 01:20:59 by stolfi BEGIN { usage = ( \ "refpoints-to-seeds \\\n" \ " [ -v scale=NUM ] \\\n" \ " [ -v labelStart=NUM ] [ -v labelStep=NUM ] \\\n" \ " < POINTSFILE > SEEDFILE" \ ); abort = -1; # Reads a list of image reference points (fragment centers, grid # refpoints, etc.) Each line must have six fields {H V X Y Z LABEL} # where {H,V} are image coordinates of the point, {X,Y,Z} are the # space coordinates (ignored), and {LABEL} is an alphanumeric label # for the point. # # For each such point, writes a seed line as expected by "pnmift", # in the format "( {H} {V} ) = {NUMLAB}" where {H,V} are # taken the input image coordinates (sclaed by {scale} and rounded # to integers) and {NUMLAB} is a numeric label, which starts at # {labelStart} parameter and is incremented by {labelStep} at each # new point. if (scale == "") { scale = 1.0; } if (labelStart == "") { labelStart = 1; } if (labelStep == "") { labelStep = 0; } nextLabel = labelStart; } (abort >= 0) { exit abort; } //{ gsub(/[#].*$/, "", $0); } /^ *$/{ next; } (NF == 6){ pt_h = $1; pt_v = $2; printf "( %4d %4d ) = %03d\n", int(scale*pt_h + 0.5), int(scale*pt_v + 0.5), nextLabel; nextLabel += labelStep; next; } /./ { data_error(("malformed line \"" $0 "\"")); } function data_error(msg) { printf "%d: **%s\n", FNR, msg > "/dev/stderr"; abort = 1; exit abort; }