#! /bin/bash # Last edited on 2008-11-23 23:51:33 by stolfi USAGE="compare-pgm-scales {IMG_DIR} {PGM_FILE_1} {PGM_FILE_2}" imgdir="$1"; shift; image1="$1"; shift; image2="$1"; shift; # Extracts 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}/calib_${br1}_${ct1}_${br2}_${ct2}_${ch1}.eps" dfile="${imgdir}/dhist_${br1}_${ct1}_${br2}_${ct2}_${ch1}.eps" tmp="/tmp/$$" i=0 for img in ${image1} ${image2} ; do cat ${imgdir}/${img} \ | pnmnoraw \ | tr ' ' '\012' \ | tr -s '\012' \ | sed -e '1,4d' \ > ${tmp}-${i}.dat wc -l ${tmp}-${i}.dat i=$(( ${i} + 1 )) done paste -d' ' ${tmp}-0.dat ${tmp}-1.dat \ | sort -k1,1n \ > ${tmp}.dat printf "lo pair: "; head -1 ${tmp}.dat 1>&2 printf "hi pair: "; tail -1 ${tmp}.dat 1>&2 gnuplot < +30) { d = +30; } printf "%d\n", d; } ' \ | sort -k1,1g \ | uniq -c \ > ${tmp}-dh.dat gnuplot <