#!/bin/csh -f
# 19.08.92 v1.00 unionpic001 Keven Fedirko + Alex Urrutia
#
# This is a description of how to create two pictures that you want to have
# the same pixels that are common to each picture file.  The composite
# program will be used to first find the "different" pixels in each image.
# The contrast program will generate a high-contrast image from the
# picture file output with the composite program.  Because it is high-
# contrast the anti-aliasing will be lost, since there is no way for the
# program to "know" which pixels are edges.  The "correct" alpha channel
# of the common-pixel image needs to be created.  This is done with the
# alpha program.  In this case the red channel is used.  A black frame is
# created the same size as the original pictures.  This will be used to
# adopt the correct alpha channel for compositing purposes.  Then the
# composite program is used to overlay the two original images, and the
# black_alpha file is layed on top.  This will produce the desired output
# file.  Voila!  This is an interactive version of the "commonpic" series.

if ($#argv < 3) then
	echo
	echo "Usage: unionpic <input1> <input2> <output> "
	echo
	exit -1
endif
infopic $1>test.info
set width=`cat test.info|awk '/width/{printf("%s",$3)}'`
set height=`cat test.info|awk '/height/{printf("%s",$3)}'`

#diffpic $1 $2 -o test_ab -i
composite test_ab -v $1 $2 -D
gradation black $width $height -v 0 0 0 0 0 0 -V
contrast test_ab test_ab_con .001 -v
alpha test_ab_con test_ab_con_alpha 1 0 1 0 0 0 0 -v
getalpha black test_ab_con_alpha black_alpha
composite $3 -v $1 $2 black_alpha
rm test_ab*.pic
rm black*.pic
rm test.info
