core.postprocessing
Class Periodify

java.lang.Object
  extended bycore.postprocessing.Periodify

public class Periodify
extends java.lang.Object

Blends together frames of an animation to produce a continuous loop. An output image sequence is created by blending together pairs of images from an input image sequence. The contrast is adjusted, assuming that the image pairs are uncorrelated.

Version:
1.0
Author:
Andreas Sundquist

Field Summary
(package private) static byte[] bytes
           
(package private) static java.io.FileOutputStream file
           
(package private) static int frames
          Number of output sequence frames.
(package private) static int height
          Height of the image.
(package private) static java.lang.String infname
          Input sequence filename.
(package private) static java.lang.String outfname
          Output sequence filename.
(package private) static int overlap
          Number of overlap frames.
(package private) static int width
          Width of the image.
 
Constructor Summary
Periodify()
           
 
Method Summary
(package private) static void Blend(byte[] buf0, byte[] buf1, double blend, byte[] buf)
          Blends together two images "buf0" and "buf1" to produce "buf" using the blending coefficient "blend".
(package private) static double blend(int frame)
          Returns the blending coefficient for output frame "frame".
(package private) static int frame0(int frame)
          Returns one of the input images to blend for output frame "frame".
(package private) static int frame1(int frame)
          Returns the other input image to blend for the output frame "frame".
(package private) static int i(byte b)
          For byte b >= 0 return int b, otherwise return 256 + int b.
(package private) static void LoadMonoTGA(java.lang.String fname, byte[] buf)
          Loads a monochrome TGA image specified by "fname" into the byte buffer "buf".
static void main(java.lang.String[] args)
          Creates and writes the blended image files.
private static java.lang.String PadZeros(int x, int len)
          Returns a string representation of "x" that is padded with zeros up to a length "len".
private static void print(java.lang.String s)
          Output routine for strings.
private static void println(java.lang.String s)
          Output routine for strings.
(package private) static int round(double x)
          Round a double up to the nearest integer.
(package private) static void SaveMonoTGA(java.lang.String fname, byte[] buf)
          Writes a monochrome TGA image specified by "fname" using the image data in "buf", and the image dimensions specified by "width" and "height".
(package private) static void WriteByte(int x)
          Write byte to file.
(package private) static void WriteWord(int x)
          Write word to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

static int width
Width of the image.


height

static int height
Height of the image.


infname

static java.lang.String infname
Input sequence filename.


outfname

static java.lang.String outfname
Output sequence filename.


frames

static int frames
Number of output sequence frames.


overlap

static int overlap
Number of overlap frames. Note that the input file we are blending must have (frames+overlap) number of frames total (counting from 0) or the program will terminate trying to read a non-existent image file. For example, if frames = 100 and overlap = 30, then the input image files must be numbered from 0 to 129, that is, there are 130 of them.


file

static java.io.FileOutputStream file

bytes

static byte[] bytes
Constructor Detail

Periodify

public Periodify()
Method Detail

frame0

static int frame0(int frame)
Returns one of the input images to blend for output frame "frame".

Parameters:
frame - The number of the output frame to be blended.
Returns:
The number of the input frame from the first part of that series to be blended.

frame1

static int frame1(int frame)
Returns the other input image to blend for the output frame "frame".

Parameters:
frame - The number of the output frame to be blended.
Returns:
The number of the input frame from the upper part of that series to be blended.

blend

static double blend(int frame)
Returns the blending coefficient for output frame "frame". The pair of input images are blended in a linear fashion, where a blending coefficient of 0.0 produces the input image specified by frame0(), and 1.0 produces the input image specified by frame1().

Parameters:
frame - The number of the output frame to be blended.
Returns:
The faction of the image from the first part of the input series to be added into the blend. Note that the fraction of the image from the upper part of the input series to be blended into the output frame is 1 minus this number.

main

public static void main(java.lang.String[] args)
Creates and writes the blended image files.


LoadMonoTGA

static void LoadMonoTGA(java.lang.String fname,
                        byte[] buf)
Loads a monochrome TGA image specified by "fname" into the byte buffer "buf". The buffer "buf" needs to be at least of size width*height.

Parameters:
fname - The name of the input TGA image.
buf - The buffer into which the image is loaded.

SaveMonoTGA

static void SaveMonoTGA(java.lang.String fname,
                        byte[] buf)
Writes a monochrome TGA image specified by "fname" using the image data in "buf", and the image dimensions specified by "width" and "height".

Parameters:
fname - The name of the input TGA image.
buf - The buffer into which the image has been loaded.

Blend

static void Blend(byte[] buf0,
                  byte[] buf1,
                  double blend,
                  byte[] buf)
Blends together two images "buf0" and "buf1" to produce "buf" using the blending coefficient "blend". A value of 0.0 reproduces "buf0", while a value of 1.0 reproduces "buf1", and 0.5 is half way between the two.

Parameters:
buf0 - The first image to be blended.
buf1 - The second image to be blended.
blend - The blending coefficient (blend = 0 gives all "buf0").
buf - The blended image.

i

static int i(byte b)
For byte b >= 0 return int b, otherwise return 256 + int b.

Parameters:
b - The byte.
Returns:
The integer defined above.

round

static int round(double x)
Round a double up to the nearest integer.

Parameters:
x - The double to be rounded.
Returns:
The integer.

WriteByte

static void WriteByte(int x)
               throws java.io.IOException
Write byte to file.

Parameters:
x - The byte to be written.
Throws:
java.io.IOException

WriteWord

static void WriteWord(int x)
               throws java.io.IOException
Write word to file.

Parameters:
x - The word to be written.
Throws:
java.io.IOException

PadZeros

private static java.lang.String PadZeros(int x,
                                         int len)
Returns a string representation of "x" that is padded with zeros up to a length "len". For example, (x,len) = (12,4) we return "0012"

Parameters:
x - The string for the maximum number of pad zeroes.
len - The length of the output string that is x plus the padding zeroes.
Returns:
The padded string.

println

private static void println(java.lang.String s)
Output routine for strings.

Parameters:
s - The string to be output.

print

private static void print(java.lang.String s)
Output routine for strings.

Parameters:
s - The string to be output.