framed
Class Slope

java.lang.Object
  extended by framed.Slope
All Implemented Interfaces:
FrameSource

public class Slope
extends java.lang.Object
implements FrameSource

Use a Slope object to compute derivatives of a static input frame. Currently supported are derivatives up to the order of 3. Use the Context class to specify the desired derivatives and their context. Each derivative may be computed over a different context. Tirol smoothing (x[i] = x[i-1]/4 + x[i]/2 + x[i+1]/4) is enabled by default.

Author:
sikoried

Nested Class Summary
static class Slope.Context
          The Context class holds all information necessary to compute derivatives.
 
Field Summary
static int PAD_COPY
          pad with the most recently read valid data
 
Constructor Summary
Slope(FrameSource source)
          Generate the default Slope object; computes the first derivative over a context of 3 frames.
Slope(FrameSource source, Slope.Context[] contexts)
          Generate a specific Slope object for the given contexts
 
Method Summary
static Slope create(FrameSource source, java.lang.String parameterString)
          Create a new Slope object which computes the specified deltas on the connected source
 int getFrameSize()
          Return the outgoing frame size
 boolean getTirol()
          Tirol smoothing enabled?
static void main(java.lang.String[] args)
           
 boolean read(double[] buf)
          Read and process the next frame.
 void setTirol(boolean tirol)
          Enable/disable Tirol filtering (smoothing); (x[i] = x[i-1]/4 + x[i]/2 + x[i+1]/4)
 java.lang.String toString()
          Return a String representation of the FrameSource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PAD_COPY

public static int PAD_COPY
pad with the most recently read valid data

Constructor Detail

Slope

public Slope(FrameSource source)
Generate the default Slope object; computes the first derivative over a context of 3 frames.

Parameters:
source -

Slope

public Slope(FrameSource source,
             Slope.Context[] contexts)
Generate a specific Slope object for the given contexts

Parameters:
source -
contexts - derivatives to compute
See Also:
Slope.Context
Method Detail

create

public static Slope create(FrameSource source,
                           java.lang.String parameterString)
                    throws MalformedParameterStringException
Create a new Slope object which computes the specified deltas on the connected source

Parameters:
source - FrameSource to connect to
parameterString - "context-size:order[,context-size:order,...]
Returns:
Throws:
MalformedParameterStringException

getFrameSize

public int getFrameSize()
Return the outgoing frame size

Specified by:
getFrameSize in interface FrameSource

getTirol

public boolean getTirol()
Tirol smoothing enabled?

Returns:

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

read

public boolean read(double[] buf)
             throws java.io.IOException
Read and process the next frame. There are three states: beginning-of-stream, in-stream and end-of-stream. The first read call fills the context using the specified padding method. While in-stream, computation is trivial. When reaching end-of-stream, the index is remembered, and a new padding frame is inserted until no genuine data is available.

Specified by:
read in interface FrameSource
Parameters:
buf - buffer to save the frame; implementing objects may depend on a constant dimensionduring subsequent calls
Returns:
true on success, false if the stream terminated before the window was filled
Throws:
java.io.IOException

setTirol

public void setTirol(boolean tirol)
Enable/disable Tirol filtering (smoothing); (x[i] = x[i-1]/4 + x[i]/2 + x[i+1]/4)

Parameters:
tirol -

toString

public java.lang.String toString()
Description copied from interface: FrameSource
Return a String representation of the FrameSource

Specified by:
toString in interface FrameSource
Overrides:
toString in class java.lang.Object