ptolemy.domains.sdf.lib.vq
Class ImageSequence

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.actor.lib.Source
                              extended by ptolemy.domains.sdf.lib.vq.ImageSequence
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class ImageSequence
extends Source

Load a sequence of binary images from files, and create a sequence of IntMatrixTokens from them. The data is assumed to row scanned, starting at the top row. Each byte of the binary file is assumed to be the greyscale intensity of a single pixel in the image.

The files to be loaded are specified as relative URLs from the base URL path. Usually the base path should be set to the root ptolemy classpath. The file names are created by replacing *'s in the filename with consecutive integers (using zero padding). For example, specifying a URLtemplate of "missa***.qcf" and a starting frame of zero, will create the names:

The name manufacturing algorithm is not especially robust, so debug listeners attached to this actor will receive a list of the file names. This actor could be greatly expanded to use the Java Advanced Imaging API for loading images.

Since:
Ptolemy II 0.2
Version:
$Id: ImageSequence.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Steve Neuendorffer
See Also:
Serialized Form
Accepted Rating:
Red
Proposed Rating:
Yellow (neuendor)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private  int _endFrame
           
private  byte[] _frameBytes
           
private  int _frameCount
           
private  int[][] _frameInts
           
private  int _frameNumber
           
private  int _imageColumns
           
private  int _imageRows
           
private  IntMatrixToken[] _images
           
private  int _startFrame
           
 Parameter endFrame
          The ending frame number.
 Parameter imageColumns
          The number of columns in each image.
 Parameter imageRows
          The number of rows in each image.
 Parameter imageURLTemplate
          The image filename templates.
 Parameter startFrame
          The starting frame number.
 
Fields inherited from class ptolemy.actor.lib.Source
output, trigger
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
ImageSequence(CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
private  int _fullRead(java.io.InputStream s, byte[] b)
           
 void fire()
          Fire this actor.
 void initialize()
          Initialize this actor.
 
Methods inherited from class ptolemy.actor.lib.Source
prefire
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

imageURLTemplate

public Parameter imageURLTemplate
The image filename templates.


imageColumns

public Parameter imageColumns
The number of columns in each image.


imageRows

public Parameter imageRows
The number of rows in each image.


startFrame

public Parameter startFrame
The starting frame number.


endFrame

public Parameter endFrame
The ending frame number.


_frameCount

private int _frameCount

_images

private IntMatrixToken[] _images

_frameBytes

private byte[] _frameBytes

_frameInts

private int[][] _frameInts

_imageColumns

private int _imageColumns

_imageRows

private int _imageRows

_startFrame

private int _startFrame

_endFrame

private int _endFrame

_frameNumber

private int _frameNumber
Constructor Detail

ImageSequence

public ImageSequence(CompositeEntity container,
                     java.lang.String name)
              throws IllegalActionException,
                     NameDuplicationException
Construct an actor with the given container and name.

Parameters:
container - The container.
name - The name of this actor.
Throws:
IllegalActionException - If the actor cannot be contained by the proposed container.
NameDuplicationException - If the container already has an actor with this name.
Method Detail

initialize

public void initialize()
                throws IllegalActionException
Initialize this actor. Read in the image files.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class AtomicActor
Throws:
IllegalActionException - If any of the input files could not be read.

fire

public void fire()
          throws IllegalActionException
Fire this actor. Output the next image in the sequence. If the sequence has no more images, then loop back to the first image in the sequence.

Specified by:
fire in interface Executable
Overrides:
fire in class Source
Throws:
IllegalActionException - Not thrown in this base class.

_fullRead

private int _fullRead(java.io.InputStream s,
                      byte[] b)
               throws java.io.IOException
Throws:
java.io.IOException