#! /bin/bash # Last edited on 2008-11-23 23:58:32 by stolfi USAGE="show-pgm-hist {IMG_DIR} {PGM_FILE_1} {PGM_FILE_2}" imgdir="$1"; shift; image1="$1"; shift; image2="$1"; shift; # Extract the brightness and contrast from file names. # Assumes file names are "B{BBB}_C{CCC}_{CHANNEL}.pgm" fld1=( `echo ${image1} | sed -e 's:.*/::' | tr '._' ' '` ) fld2=( `echo ${image2} | sed -e 's:.*/::' | tr '._' ' '` ) br1="${fld1[0]}"; ct1="${fld1[1]}"; ch1="${fld1[2]}" br2="${fld2[0]}"; ct2="${fld2[1]}"; ch2="${fld2[2]}" if [[ "/${ch1}" != "/${ch2}" ]]; then echo "incompatible channels ${ch1} ${ch2}"; exit 1 fi ofile="${imgdir}/hist_${br1}_${ct1}_${br2}_${ct2}_${ch1}.eps" tmp="/tmp/$$" i=0 for img in ${image1} ${image2} ; do pgmhist ${imgdir}/${img} \ | egrep -e '^[ ]*[0-9]' \ | gawk \ ' BEGIN{ v = 0;} //{ while ($1 > v) { print v, 0; v++; } print; v = $1; } ' \ > ${tmp}-${i}.dat wc -l ${tmp}-${i}.dat i=$(( ${i} + 1 )) done gnuplot <