#! /bin/bash # Last edited on 2003-02-05 02:54:12 by stolfi usage="${0##*/} SCALE EXPANSION" # Reads a PGM image containing a binary mask from standard input. Magnifies it # by the given SCALE factor, by smooth interpolation, and thresholds it # at the 0.5 level. Then expands it by the given EXPANSION (which may be # negative for contraction). if [ $# -ne 2 ]; then echo "usage: ${usage}"; exit 1; fi scale="$1"; shift; expand="$1"; shift; level=0.25 if [ ${expand} -lt 0 ]; then expand=$(( -expand )); level=0.75; fi pnmscale ${scale} \ | pgmmedf \ -window $((2 * scale + 1)) $((2 * scale + 1)) \ -round -level 0.5 \ | pgmmedf \ -window $((2 * expand + 1)) $((2 * expand + 1)) \ -round -level ${level} exit 0