#! /bin/tcsh -f # Last edited on 2008-02-04 20:31:26 by stolfi set cmd = "$0"; set cmd = "${cmd:t}" set usage = "${cmd} IMG" # Combines three photometric stereo images # "{IMG}a-L.png", "{IMG}b-L.png", "{IMG}c-L.png" # (same camera, different lights) into a single image. # Assumes that the images have been properly aligned and cropped # to the same size. Writes the output to "{IMG}m-L.png" . # # All input and output files reside in the "raw-aligns" directory. if ( $#argv != 1 ) then echo "usage: ${usage}"; exit 1 endif set img = "$1"; shift; set wa = 0.3333333 set wb = 0.3333333 set wc = 0.3333333 set indir = ${STOLFIHOME}/projects/fragments/IAB-2002/raw-aligns set otdir = ${STOLFIHOME}/projects/fragments/IAB-2002/raw-aligns (cd ${indir}/. ) set tmp = /tmp/$$ set imgin = "${indir}/${img}" set imgot = "${otdir}/${img}" echo "averaging ${imgin}{a,b,c}-L.png -> ${imgot}m-L.png" cat ${imgin}a-L.png \ | convert png:- ppm:- \ | ppmnorm -wpercent 5 \ > ${tmp}a.ppm cat ${imgin}b-L.png \ | convert png:- ppm:- \ | ppmnorm -wpercent 5 \ > ${tmp}b.ppm cat ${imgin}c-L.png \ | convert png:- ppm:- \ | ppmnorm -wpercent 5 \ > ${tmp}c.ppm pnmxarith -mix ${wa} ${wb} ${tmp}a.ppm ${tmp}b.ppm > ${tmp}ab.ppm pnmxarith -mix 1.000 ${wc} ${tmp}ab.ppm ${tmp}c.ppm > ${tmp}m.ppm convert ${tmp}m.ppm ${imgot}m-L.png convert -quality 95 -geometry 512 ${imgot}m-L.png ${imgot}m-L-s.jpg /bin/rm -f ${tmp}*.ppm