

   BETA RELEASE 

  Morphine:   A simple morphing program         Mark Hall
                                               foo@cs.rice.edu
                                               hall@siggraph.org
           January 9, 1992


   The files in this directory are source and examples for a 
simple morphing program. The algorithm is a simple one: distort
an input texture and blend in more and more of another texture.
The results are displayed in an X window, and optionally stored
as a series of GIF files.

   This code is public domain, at least as far as I can make it so.
I grabbed source from the Graphics Gems library for drawing 
triangles, and used xv source code to read and write gifs. 

   The idea is to let the net play with this for a while, then 
send out an 'official' version.  Any help you, the user, can give 
me on making it more portable are welcome. I have compiled and run 
this program on Sun4, vax, rs6000(although you need to add -Drs6000
to the CFLAGS in Makefile) and SGI. That's all I have to play with 
around here. I may be doing things poorly in X, so any pointers 
there are welcome.

   The 'test' files in this directory are examples.

   mail comments/bugfixes/flames  to foo@cs.rice.edu

Usage: 

	morphine <filename>

    file format: 
	starttexture <giffile1>
	endtexture   <giffile2>
	backgroundtexture <giffile3>
	numtris <number of triangular regions>
	steps   <number of morphing steps>
	colordiff <number between 0 and 768, to define "close enough" colors> 
	< <outputgifs>  <filename> >  <-optional

	<starting texture coordinates, at beginning of sequence>
	<starting texture coordinates, at end       of sequence>
	<final    texture coordinates, at beginning of sequence>
	<final    texture coordinates, at end       of sequence>
	<output   texture coordinates, at beginning of sequence>
	<output   texture coordinates, at end       of sequence>


     The coordinates are groups of three XY coordinates within the 
     texture file. They define triangular regions of texture.
     There is a starting and ending coordinate for each corner, 
     so the input texture can change over time, for example. 
     So far, I have only changed the position of the output texture
     in my examples.


Random thoughts: 

   Early on, I decided to use gif files for input and output, 
because it was easy. Many source pictures are available in GIF 
format. I also use 8-bit images internally, so blending 
between colors can be tricky, and aliasing is bad. The current 
color lookup is very slow. 

   I haven't been able to get the Digital Image Warping book yet.

   There are no doubt great speedups possible because this code 
was written in 8 days, and I am not that familiar with X, GIFS, 
etc.  In particular, some things that are floats could probably 
be ints. Some char (or byte) variables should probably be ints, etc.

   The user interface for creating files is non-existant.
I used xv and the mouse functions there to get coordinates, and did 
the rest by hand.


   





TODO list: 

    clean up unused things from xv and GraphicsGems code

    make X output otpional ?

    find faster color-lookup algorithm

    make a x-based program to enter coordinates 

    maybe I can figure out how to update an X colormap nicely (no
    flicker) and double-buffer

    look at "numcolors" for the gifs. Try to make it not have to be 
    a power of 2.

    implement better (non-sampling) lookup of color of warped textures.
    each output pixel really covers a non-zero area of the input texture.
 
    internally use 24-bit images, then use color quantization 
	to redo color map for aliasing problems