#!/bin/bash
#
# summer.sh - a script to subtract a baseline image from a sequence
#             of images, then sum them up into one big composite image.
#
# author: igor.senderovich at uconn.edu
# version: 4/28/2011
#

workingform=tif

if [ $# -lt 2 ]; then
  echo "Usage: summer.sh <list of more than one image file>"
  exit 1
fi

# take the first image in the set as the baseline for the others

blimage=$1
shift
echo $1
echo $* |\
#awk 'BEGIN{RS=" "}{print "composite -compose minus -depth 16",$1,"'$blimage'",$1".'$workinfgform'"}' | sh

# now sum up the baseline-subtracted images into a composite

compimage=${blimage}.$workingform
firstimage=$1.$workingform
echo compimage is $compimage
cp $firstimage $compimage
shift
echo $* |\
awk 'BEGIN{RS=" "}{print "composite -compose plus -depth 16",$1".'$workingform'","'$compimage\ $compimage'"}' 
echo blimage is ${blimage}.$workingform
