ptolemy.actor.lib.jai
Class JAIEdgeDetection

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.Transformer
                              extended by ptolemy.actor.lib.jai.JAIEdgeDetection
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 JAIEdgeDetection
extends Transformer

An actor that does edge detection on a image. This is done by taking the image and separately convolving it with two different masks. The two results are squared, summed together, and square rooted to give the final image. The user may specify one, or both masks. A series of predefined masks are available for the user to use.

Since:
Ptolemy II 3.0
Version:
$Id: JAIEdgeDetection.java 57040 2010-01-27 20:52:32Z cxh $
Author:
James Yeh
See Also:
Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private static int _BACKDIAGONAL
           
private static float[] _backDiagonalFilter
           
private static int _DIAGONAL
           
private static float[] _diagonalFilter
           
private  javax.media.jai.KernelJAI _firstKernelJAI
          The KernelJAI's that contain the masks to be used in edge detection.
private  int _firstMask
          The choice of mask.
private  DoubleMatrixToken _firstMaskData
          The ArrayTokens contained the the User Specified Mask Fields
private static float[] _freiAndChenHorizontalFilter
           
private static float[] _freiAndChenVerticalFilter
           
private static int _FREICHEN_HORIZONTAL
           
private static int _FREICHEN_VERTICAL
           
private  double[][] _initialMatrix
           
private static int _PREWITT_HORIZONTAL
           
private static int _PREWITT_VERTICAL
           
private static float[] _prewittHorizontalFilter
           
private static float[] _prewittVerticalFilter
           
private static int _ROBERTS_HORIZONTAL
           
private static int _ROBERTS_VERTICAL
           
private static float[] _robertsHorizontalFilter
           
private static float[] _robertsVerticalFilter
           
private  javax.media.jai.KernelJAI _secondKernelJAI
           
private  int _secondMask
           
private  DoubleMatrixToken _secondMaskData
           
private static int _SOBEL_HORIZONTAL
           
private static int _SOBEL_VERTICAL
           
private static float[] _sobelHorizontalFilter
          Prespecified masks that the user may use
private static float[] _sobelVerticalFilter
           
private static int _TRANSPARENT
           
private static float[] _transparentFilter
           
private static int _USER_SPECIFIED
           
private static int _ZERO_FILTER
           
private static float[] _zeroFilter
           
 StringAttribute firstMask
          The following two parameters are used to specify the masks used for edge detection.
 StringAttribute secondMask
          The mask used for edge detection.
 Parameter userSpecifiedFirstMask
          The first user specified mask, and its corresponding x and y dimensions.
 Parameter userSpecifiedSecondMask
          The second user specified mask, and its corresponding x and y dimensions.
 
Fields inherited from class ptolemy.actor.lib.Transformer
input, output
 
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
JAIEdgeDetection(CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
private  javax.media.jai.KernelJAI _filterAssigner(int choice)
          If the user chooses to use a prespecified mask, then this method will assign the mask values to a KernelJAI used in edge detection.
private  javax.media.jai.KernelJAI _maskFiller(DoubleMatrixToken matrix)
          If a user decides not to use a prespecified mask, this method will return a KernelJAI filled with user specified values.
private  int _maskNumberer(java.lang.String maskName)
          A convenience method to help in assinging masks.
 void attributeChanged(Attribute attribute)
          Override the base class and set change private variables if the attribute corresponding to it has changed.
 void fire()
          Fire this actor.
 
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, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, 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, 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, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, 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

firstMask

public StringAttribute firstMask
The following two parameters are used to specify the masks used for edge detection. Traditionally one mask is used for horizontal edge detection, and one mask is used for vertical edge detection. The following predefined masks are available: Sobel horizontal mask. Sobel vertical mask. Roberts horizontal mask. Roberts vertical mask. Prewitt horizontal mask. Prewitt vertical mask. Frei and Chen horizontal mask. Frei and Chen vertical mask. A diagonal mask, which finds edges in the direction of a slash. A back diagonal mask, which finds edges in the direction of a backslash. A Transparent mask. Using this mask allows you to find edges in one direction and add them back to the original image. A mask of zeros. The default mask for the first choice is a Sobel horizontal mask. The default mask for the second choice is a Sobel vertical mask. The user can also specify mask(s). The dimensions of the mask(s) must be specified if the user chooses to do so.


secondMask

public StringAttribute secondMask
The mask used for edge detection.

See Also:
firstMask

userSpecifiedFirstMask

public Parameter userSpecifiedFirstMask
The first user specified mask, and its corresponding x and y dimensions. The Default mask is the transparent mask, and the default x and y dimensions is 3.


userSpecifiedSecondMask

public Parameter userSpecifiedSecondMask
The second user specified mask, and its corresponding x and y dimensions. The Default mask is the transparent mask, and the default x and y dimensions is 3.


_firstMaskData

private DoubleMatrixToken _firstMaskData
The ArrayTokens contained the the User Specified Mask Fields


_secondMaskData

private DoubleMatrixToken _secondMaskData

_firstKernelJAI

private javax.media.jai.KernelJAI _firstKernelJAI
The KernelJAI's that contain the masks to be used in edge detection.


_secondKernelJAI

private javax.media.jai.KernelJAI _secondKernelJAI

_firstMask

private int _firstMask
The choice of mask.


_secondMask

private int _secondMask

_initialMatrix

private double[][] _initialMatrix

_sobelHorizontalFilter

private static final float[] _sobelHorizontalFilter
Prespecified masks that the user may use


_sobelVerticalFilter

private static final float[] _sobelVerticalFilter

_robertsHorizontalFilter

private static final float[] _robertsHorizontalFilter

_robertsVerticalFilter

private static final float[] _robertsVerticalFilter

_prewittHorizontalFilter

private static final float[] _prewittHorizontalFilter

_prewittVerticalFilter

private static final float[] _prewittVerticalFilter

_freiAndChenHorizontalFilter

private static final float[] _freiAndChenHorizontalFilter

_freiAndChenVerticalFilter

private static final float[] _freiAndChenVerticalFilter

_transparentFilter

private static final float[] _transparentFilter

_zeroFilter

private static final float[] _zeroFilter

_diagonalFilter

private static final float[] _diagonalFilter

_backDiagonalFilter

private static final float[] _backDiagonalFilter

_BACKDIAGONAL

private static final int _BACKDIAGONAL
See Also:
Constant Field Values

_DIAGONAL

private static final int _DIAGONAL
See Also:
Constant Field Values

_FREICHEN_HORIZONTAL

private static final int _FREICHEN_HORIZONTAL
See Also:
Constant Field Values

_FREICHEN_VERTICAL

private static final int _FREICHEN_VERTICAL
See Also:
Constant Field Values

_PREWITT_HORIZONTAL

private static final int _PREWITT_HORIZONTAL
See Also:
Constant Field Values

_PREWITT_VERTICAL

private static final int _PREWITT_VERTICAL
See Also:
Constant Field Values

_ROBERTS_HORIZONTAL

private static final int _ROBERTS_HORIZONTAL
See Also:
Constant Field Values

_ROBERTS_VERTICAL

private static final int _ROBERTS_VERTICAL
See Also:
Constant Field Values

_SOBEL_HORIZONTAL

private static final int _SOBEL_HORIZONTAL
See Also:
Constant Field Values

_SOBEL_VERTICAL

private static final int _SOBEL_VERTICAL
See Also:
Constant Field Values

_TRANSPARENT

private static final int _TRANSPARENT
See Also:
Constant Field Values

_USER_SPECIFIED

private static final int _USER_SPECIFIED
See Also:
Constant Field Values

_ZERO_FILTER

private static final int _ZERO_FILTER
See Also:
Constant Field Values
Constructor Detail

JAIEdgeDetection

public JAIEdgeDetection(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

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
Override the base class and set change private variables if the attribute corresponding to it has changed.

Overrides:
attributeChanged in class NamedObj
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the function is not recognized, or if a contained method throws it.

fire

public void fire()
          throws IllegalActionException
Fire this actor. Output the edge detected image.

Specified by:
fire in interface Executable
Overrides:
fire in class AtomicActor
Throws:
IllegalActionException - If a contained method throws it.

_filterAssigner

private javax.media.jai.KernelJAI _filterAssigner(int choice)
                                           throws IllegalActionException
If the user chooses to use a prespecified mask, then this method will assign the mask values to a KernelJAI used in edge detection.

Throws:
IllegalActionException - If the choice value is out of range.

_maskFiller

private javax.media.jai.KernelJAI _maskFiller(DoubleMatrixToken matrix)
If a user decides not to use a prespecified mask, this method will return a KernelJAI filled with user specified values.


_maskNumberer

private int _maskNumberer(java.lang.String maskName)
                   throws IllegalActionException
A convenience method to help in assinging masks.

Throws:
IllegalActionException