org.shapelogic.imageprocessing
Class BaseVectorizer

java.lang.Object
  extended by org.shapelogic.imageprocessing.BaseVectorizer
All Implemented Interfaces:
ij.plugin.filter.PlugInFilter, IPixelTypeFinder, PixelJumperByte
Direct Known Subclasses:
MaxDistanceVectorizer, ShortLineBasedVectorizer

public abstract class BaseVectorizer
extends java.lang.Object
implements ij.plugin.filter.PlugInFilter, IPixelTypeFinder

Input image needs to be binary, that is gray scale with inverted LUT. That the background is white, 0, and the foreground is black, 255. When it handles a point it will mark a point as used and what type it has. I put the result in a polygon. How do I know where to start? I will start taking the pixels until I meet the first black pixel, and I will work out from there. Cycle starting at (1,0) to (1,1) to (0,1) so in what would normally be counter clockwise, but since the coordinate system is turned upside down it is clockwise Terminology: Current: the short line that is currently handled Short line: there are 2 pieces, a short line at the end and everything before that

Author:
Sami Badawi

Field Summary
protected  byte _currentDirection
           
protected  int _currentPixelIndex
          this is the index into the _pixels where the current point is
protected  CPointInt _currentPoint
          last point where you are
protected  int[] _cyclePoints
          What you need to add to the the index in the pixels array to get to the indexed point
protected  java.util.List<java.util.Set<IPoint2D>> _endPointsClusters
           
protected  java.lang.String _errorMessage
           
protected  int _firstPointInLineIndex
           
protected  CPointInt _firstPointInMultiLine
           
protected  java.lang.Object _matchingOH
           
protected  int _maxX
           
protected  int _maxY
           
protected  int _minX
           
protected  int _minY
           
protected  int _numberOfPointsInAllLines
           
protected  byte[] _pixels
           
protected  PixelTypeCalculator _pixelTypeCalculator
           
protected  IPixelTypeFinder _pixelTypeFinder
           
protected  NumericRule[] _rulesArrayForLetterMatching
           
protected  java.util.ArrayList<CPointInt> _unfinishedPoints
           
static int MAX_DISTANCE_BETWEEN_CLUSTER_POINTS
           
static java.lang.String POLYGON
           
static java.lang.String RAW_POLYGON
           
static byte STRAIGHT_LINE_COLOR
           
 
Fields inherited from interface ij.plugin.filter.PlugInFilter
CONVERT_TO_FLOAT, DOES_16, DOES_32, DOES_8C, DOES_8G, DOES_ALL, DOES_RGB, DOES_STACKS, DONE, FINAL_PROCESSING, NO_CHANGES, NO_IMAGE_REQUIRED, NO_UNDO, PARALLELIZE_STACKS, ROI_REQUIRED, SNAPSHOT, STACK_REQUIRED, SUPPORTS_MASKING
 
Constructor Summary
BaseVectorizer()
           
 
Method Summary
protected  void addToUnfinishedPoints(CPointInt newPoint)
           
 int countRegionCrossingsAroundPoint(int pixelIndex)
          A normal line has a crossing index of 4.
protected  void drawLine(CLine line)
           
protected  void drawLines()
          Draws the vectorized lines on the original image for visual inspection.
protected  void findAllLines()
           
protected  boolean findFirstLinePoint()
           
protected abstract  void findMultiLine()
           
protected  void findMultiLinePostProcess()
          To be overridden.
protected  boolean findMultiLinePreProcess()
           
 PixelTypeCalculator findPointType(int pixelIndex, PixelTypeCalculator reusedPixelTypeCalculator)
           
 Polygon getCleanedupPolygon()
           
 int[] getCyclePoints()
          What you need to add to the the index in the pixels array to get to the indexed point.
 java.lang.String getErrorMessage()
           
 java.lang.Object getMatchingOH()
           
 int getMaxX()
           
 int getMaxY()
           
 int getMinX()
           
 int getMinY()
           
 byte[] getPixels()
           
 java.util.Collection<IPoint2D> getPoints()
           
 Polygon getPolygon()
           
protected abstract  byte handleProblematicPoints()
           
protected  void init(ij.process.ImageProcessor ip)
          Cannot handle the last pixel at the edge, so for now just ignore it.
protected abstract  void internalFactory()
          All the objects that needs special version should be created here.
 boolean isGuiEnabled()
          To be overridden.
 boolean isPixelUsed(int pixelIndex)
          Not background and the used bit set to 0
protected abstract  boolean lastPixelOk(byte newDirection)
           
protected  void matchLines()
          This does really not belong in a vectorizer.
protected  void moveCurrentPointForwards(byte newDirection)
           
static byte oppesiteDirection(byte direction)
           
 CPointInt pixelIndexToPoint(int pixelIndex)
           
 int pointToPixelIndex(int x, int y)
           
 int pointToPixelIndex(IPoint2D point)
           
protected  Polygon polygonFactory()
           
 void run(ij.process.ImageProcessor ip)
           
 int setup(java.lang.String arg, ij.ImagePlus imp)
           
 void showMessage(java.lang.String text)
           
 void showMessage(java.lang.String title, java.lang.String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLYGON

public static final java.lang.String POLYGON
See Also:
Constant Field Values

RAW_POLYGON

public static final java.lang.String RAW_POLYGON
See Also:
Constant Field Values

MAX_DISTANCE_BETWEEN_CLUSTER_POINTS

public static final int MAX_DISTANCE_BETWEEN_CLUSTER_POINTS
See Also:
Constant Field Values

STRAIGHT_LINE_COLOR

public static final byte STRAIGHT_LINE_COLOR
See Also:
Constant Field Values

_pixels

protected byte[] _pixels

_minX

protected int _minX

_maxX

protected int _maxX

_minY

protected int _minY

_maxY

protected int _maxY

_cyclePoints

protected int[] _cyclePoints
What you need to add to the the index in the pixels array to get to the indexed point


_currentPoint

protected CPointInt _currentPoint
last point where you are


_firstPointInMultiLine

protected CPointInt _firstPointInMultiLine

_pixelTypeCalculator

protected PixelTypeCalculator _pixelTypeCalculator

_unfinishedPoints

protected java.util.ArrayList<CPointInt> _unfinishedPoints

_currentPixelIndex

protected int _currentPixelIndex
this is the index into the _pixels where the current point is


_currentDirection

protected byte _currentDirection

_numberOfPointsInAllLines

protected int _numberOfPointsInAllLines

_matchingOH

protected java.lang.Object _matchingOH

_errorMessage

protected java.lang.String _errorMessage

_endPointsClusters

protected java.util.List<java.util.Set<IPoint2D>> _endPointsClusters

_firstPointInLineIndex

protected int _firstPointInLineIndex

_pixelTypeFinder

protected IPixelTypeFinder _pixelTypeFinder

_rulesArrayForLetterMatching

protected NumericRule[] _rulesArrayForLetterMatching
Constructor Detail

BaseVectorizer

public BaseVectorizer()
Method Detail

isGuiEnabled

public boolean isGuiEnabled()
To be overridden.


run

public void run(ij.process.ImageProcessor ip)
Specified by:
run in interface ij.plugin.filter.PlugInFilter

matchLines

protected void matchLines()
This does really not belong in a vectorizer.


findAllLines

protected void findAllLines()

findMultiLine

protected abstract void findMultiLine()

handleProblematicPoints

protected abstract byte handleProblematicPoints()

isPixelUsed

public boolean isPixelUsed(int pixelIndex)
Not background and the used bit set to 0


findPointType

public PixelTypeCalculator findPointType(int pixelIndex,
                                         PixelTypeCalculator reusedPixelTypeCalculator)
Specified by:
findPointType in interface IPixelTypeFinder

oppesiteDirection

public static byte oppesiteDirection(byte direction)

moveCurrentPointForwards

protected void moveCurrentPointForwards(byte newDirection)

lastPixelOk

protected abstract boolean lastPixelOk(byte newDirection)

init

protected void init(ij.process.ImageProcessor ip)
Cannot handle the last pixel at the edge, so for now just ignore it.


internalFactory

protected abstract void internalFactory()
All the objects that needs special version should be created here.


setup

public int setup(java.lang.String arg,
                 ij.ImagePlus imp)
Specified by:
setup in interface ij.plugin.filter.PlugInFilter

pointToPixelIndex

public int pointToPixelIndex(int x,
                             int y)

pointToPixelIndex

public int pointToPixelIndex(IPoint2D point)

pixelIndexToPoint

public CPointInt pixelIndexToPoint(int pixelIndex)

findFirstLinePoint

protected boolean findFirstLinePoint()

countRegionCrossingsAroundPoint

public int countRegionCrossingsAroundPoint(int pixelIndex)
A normal line has a crossing index of 4.


findMultiLinePostProcess

protected void findMultiLinePostProcess()
To be overridden. If I want to do more matching at the end.


findMultiLinePreProcess

protected boolean findMultiLinePreProcess()

addToUnfinishedPoints

protected void addToUnfinishedPoints(CPointInt newPoint)

drawLines

protected void drawLines()
Draws the vectorized lines on the original image for visual inspection. This is probably not needed in the final version of this class


showMessage

public void showMessage(java.lang.String text)

showMessage

public void showMessage(java.lang.String title,
                        java.lang.String text)

getPoints

public java.util.Collection<IPoint2D> getPoints()

drawLine

protected void drawLine(CLine line)

polygonFactory

protected Polygon polygonFactory()

getPolygon

public Polygon getPolygon()

getMatchingOH

public java.lang.Object getMatchingOH()

getErrorMessage

public java.lang.String getErrorMessage()

getCleanedupPolygon

public Polygon getCleanedupPolygon()

getCyclePoints

public int[] getCyclePoints()
Description copied from interface: PixelJumperByte
What you need to add to the the index in the pixels array to get to the indexed point.

Specified by:
getCyclePoints in interface PixelJumperByte

getMaxX

public int getMaxX()
Specified by:
getMaxX in interface PixelJumperByte

getMaxY

public int getMaxY()
Specified by:
getMaxY in interface PixelJumperByte

getMinX

public int getMinX()
Specified by:
getMinX in interface PixelJumperByte

getMinY

public int getMinY()
Specified by:
getMinY in interface PixelJumperByte

getPixels

public byte[] getPixels()
Specified by:
getPixels in interface PixelJumperByte


Copyright © 2007. All Rights Reserved.