org.shapelogic.imageprocessing
Class DirectionBasedVectorizer

java.lang.Object
  extended by org.shapelogic.imageutil.BaseImageOperation
      extended by org.shapelogic.imageprocessing.BaseVectorizer
          extended by org.shapelogic.imageprocessing.ShortLineBasedVectorizer
              extended by org.shapelogic.imageprocessing.DirectionBasedVectorizer
All Implemented Interfaces:
java.lang.Runnable, java.util.Iterator<Polygon>, IPixelTypeFinder, LazyPlugInFilter<Polygon>, PixelJumperByte, ImageOperation
Direct Known Subclasses:
DirectionBasedVectorizer_

public class DirectionBasedVectorizer
extends ShortLineBasedVectorizer

DirectionBasedVectorizer is a Vectorizer based on direction. This is special by using directions as the primary way of finding the path.

Author:
Sami Badawi

Field Summary
protected  byte[] _chainCodeForMultiLine
          All the direction from _firstPointInLine, so the direction on index 0 is point one pixel away from _firstPointInLine.
protected  int[] _directionsCount
           
protected  int _lastPointInCurrentMultiLine
           
protected  double[] _shortLineAngles
           
protected  double[] _shortLineAngleSpeeds
           
protected  int _shortLineCount
           
protected  double[] _shortLineLength
           
protected  int[] _shortLinePointIndex
           
protected static int CHAIN_CODE_FOR_MULTI_LINE_MAX_LENGTH
           
protected static int MAX_SHORT_LINE_COUNT
           
protected static int NUMBER_OF_SAME_DIRECTION_TO_START_STRAIGHT
           
 
Fields inherited from class org.shapelogic.imageprocessing.ShortLineBasedVectorizer
_angleLimit, _currentAngle, _currentCircleInterval, _currentLineType, _currentVectorDirection, _firstPointInLine, _firstUsedDirection, _maxPointsInShortLine, _pixelTypeCalculatorNextPoint, _pointsInCurrentShortLine, _secondUsedDirection, _startOfShortLinePoint, ANGLE_DIFFERENCE_LIMIT, MAX_NUMBER_OF_POINTS_IN_SHORT_LINE
 
Fields inherited from class org.shapelogic.imageprocessing.BaseVectorizer
_cleanedupPolygon, _currentDirection, _currentPixelIndex, _currentPoint, _cyclePoints, _displayInternalInfo, _endPointsClusters, _errorMessage, _firstPointInLineIndex, _firstPointInMultiLine, _matchingOH, _maxX, _maxY, _minX, _minY, _nextCount, _numberOfPointsInAllLines, _pixels, _pixelTypeCalculator, _pixelTypeFinder, _rulesArrayForLetterMatching, _stream, _streamName, _unfinishedPoints, _yForUnporcessedPixel, MAX_DISTANCE_BETWEEN_CLUSTER_POINTS, STRAIGHT_LINE_COLOR
 
Fields inherited from class org.shapelogic.imageutil.BaseImageOperation
_arg, _guiWrapper, _image, _keyValueParser, _setupReturnValue
 
Constructor Summary
DirectionBasedVectorizer()
           
 
Method Summary
static CPointInt angleFromDirectionArray(byte[] directionArray, int startDirection, int endDirection)
          Get angle from direction byte array.
protected  void findMultiLinePostProcess()
          To be overridden.
protected  boolean isStraight()
          Test if the last part of the line is straight.
protected  boolean lastPixelOk(byte newDirection)
          Change to be an up front check.
protected  void makeNewPointPostProcess()
           
protected  void moveCurrentPointForwards(byte newDirection)
           
protected  boolean multiLineHasGlobalFitness()
          Test that the current direction is close to the last direction.
 void newShortLine()
          Hook for creating new short line.
protected  int numberOfDirections(int[] directionsCount)
          Test how many of the 8 directions are represented.
protected  void splitLine(int splitIndex)
          I think that this is messing with the short lines.
 
Methods inherited from class org.shapelogic.imageprocessing.ShortLineBasedVectorizer
findMultiLine, findMultiLinePreProcess, findNextLinePoint, getAngleLimit, getMaxSinceLast, handleProblematicPoints, internalFactory, makeNewPoint, resetShortLine, setAngleLimit, setMaxSinceLast, splitLine
 
Methods inherited from class org.shapelogic.imageprocessing.BaseVectorizer
addToUnfinishedPoints, cleanPolygon, countRegionCrossingsAroundPoint, drawLine, drawLines, findAllLines, findFirstLinePoint, findPointType, getCleanedupPolygon, getCyclePoints, getErrorMessage, getImageProcessor, getMatchingOH, getMaxX, getMaxY, getMinX, getMinY, getPixels, getPoints, getPolygon, getStream, getStreamName, hasNext, init, isPixelUsed, matchLines, next, oppesiteDirection, pixelIndexToPoint, pointToPixelIndex, pointToPixelIndex, polygonFactory, remove, run, setStreamName
 
Methods inherited from class org.shapelogic.imageutil.BaseImageOperation
getGuiWrapper, getImage, getKeyValueParser, getSetupReturnValue, isImageValid, setArg, setGuiWrapper, setKeyValueParser, setSetupReturnValue, setup, showAbout, showMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAIN_CODE_FOR_MULTI_LINE_MAX_LENGTH

protected static final int CHAIN_CODE_FOR_MULTI_LINE_MAX_LENGTH
See Also:
Constant Field Values

MAX_SHORT_LINE_COUNT

protected static final int MAX_SHORT_LINE_COUNT
See Also:
Constant Field Values

NUMBER_OF_SAME_DIRECTION_TO_START_STRAIGHT

protected static final int NUMBER_OF_SAME_DIRECTION_TO_START_STRAIGHT
See Also:
Constant Field Values

_chainCodeForMultiLine

protected byte[] _chainCodeForMultiLine
All the direction from _firstPointInLine, so the direction on index 0 is point one pixel away from _firstPointInLine.


_directionsCount

protected int[] _directionsCount

_shortLineCount

protected int _shortLineCount

_shortLineAngles

protected double[] _shortLineAngles

_shortLineAngleSpeeds

protected double[] _shortLineAngleSpeeds

_shortLineLength

protected double[] _shortLineLength

_shortLinePointIndex

protected int[] _shortLinePointIndex

_lastPointInCurrentMultiLine

protected int _lastPointInCurrentMultiLine
Constructor Detail

DirectionBasedVectorizer

public DirectionBasedVectorizer()
Method Detail

multiLineHasGlobalFitness

protected boolean multiLineHasGlobalFitness()
Test that the current direction is close to the last direction.

Returns:
true if a new point should be created

lastPixelOk

protected boolean lastPixelOk(byte newDirection)
Description copied from class: ShortLineBasedVectorizer
Change to be an up front check.

Overrides:
lastPixelOk in class ShortLineBasedVectorizer

isStraight

protected boolean isStraight()
Test if the last part of the line is straight.


numberOfDirections

protected int numberOfDirections(int[] directionsCount)
Test how many of the 8 directions are represented.


moveCurrentPointForwards

protected void moveCurrentPointForwards(byte newDirection)
Overrides:
moveCurrentPointForwards in class ShortLineBasedVectorizer

newShortLine

public void newShortLine()
Description copied from class: ShortLineBasedVectorizer
Hook for creating new short line.

Overrides:
newShortLine in class ShortLineBasedVectorizer

makeNewPointPostProcess

protected void makeNewPointPostProcess()
Overrides:
makeNewPointPostProcess in class ShortLineBasedVectorizer

angleFromDirectionArray

public static CPointInt angleFromDirectionArray(byte[] directionArray,
                                                int startDirection,
                                                int endDirection)
Get angle from direction byte array. directionArray, byte array containing the 8 direction startDirection, number of first direction to accumulate endDirection, number of first direction to accumulate

Returns:
vector as a point of accumulated line

splitLine

protected void splitLine(int splitIndex)
I think that this is messing with the short lines.

Parameters:
splitIndex -

findMultiLinePostProcess

protected void findMultiLinePostProcess()
Description copied from class: BaseVectorizer
To be overridden. If I want to do more matching at the end.

Overrides:
findMultiLinePostProcess in class ShortLineBasedVectorizer


Copyright © 2009. All Rights Reserved.