org.shapelogic.imageprocessing
Class BaseParticleCounter

java.lang.Object
  extended by org.shapelogic.imageutil.BaseImageOperation
      extended by org.shapelogic.imageprocessing.BaseParticleCounter
All Implemented Interfaces:
java.lang.Runnable, RecursiveContext, IParticleCounter, ImageOperation
Direct Known Subclasses:
ColorParticleAnalyzer, ParticleCounter

public class BaseParticleCounter
extends BaseImageOperation
implements IParticleCounter, RecursiveContext

ParticleCounter count number of particles in a particle image.
This is using the SBSegmentation that is also used by Segmenter.
In this base implementation:
Find a color hypothesis.
Set everything in the background color into one segment.
Segment the rest into normal segments regardless of color.
If this is overridden then there can be more segments in the background color.
How do I know what is background colored?

Author:
Sami Badawi

Field Summary
protected  int _backgroundArea
           
protected  java.lang.Integer _backgroundColor
           
protected  int _backgroundCount
           
protected  double _boundingBoxArea
           
protected  ListStream<java.lang.String> _categorizer
           
protected  ColorHypothesis _colorHypothesis
           
protected  IColorHypothesisFinder _colorHypothesisFinder
           
protected  java.util.Map _context
           
protected  boolean _countOnly
           
protected  boolean _displayInternalInfo
           
protected  boolean _displayTable
           
protected  java.lang.Integer _inputColor
           
protected  int _iterations
           
protected  double _maxDistance
           
protected  int _maxPixelsInArea
           
protected  int _minPixelsInArea
           
protected  boolean _modifying
          Modifying colors
protected  int _paintBackground
           
protected  int _paintForground
           
protected  RecursiveContext _parentContext
           
protected  java.lang.Integer _particleCount
           
protected  java.lang.Boolean _particleImage
           
protected  java.util.List<IColorAndVariance> _particlesFiltered
           
protected  java.util.List<IColorAndVariance> _particlesOrig
           
protected  java.lang.Integer _referenceColor
           
protected  boolean _saveArea
          Create a IColorAndVariance, area for each particle.
protected  SBSegmentation _segmentation
           
protected  boolean _toMask
           
protected  boolean _useReferenceAsBackground
           
protected static int ITERATIONS_DEFAULTS
           
protected static double MAX_DISTANCE_DEFAULTS
           
protected static int MAX_PIXELS_IN_AREA_DEFAULTS
           
protected static int MIN_PIXELS_IN_AREA_DEFAULTS
           
 
Fields inherited from class org.shapelogic.imageutil.BaseImageOperation
_arg, _guiWrapper, _image, _keyValueParser, _setupReturnValue
 
Constructor Summary
BaseParticleCounter()
           
 
Method Summary
protected  void categorizeStreams()
          Analyzes particles and group them.
protected  void customStreamDefinitions()
          Define extra streams and also extra columns.
protected  void defaultColumnDefinitions()
          Setup all the stream and other needed things.
protected  void defaultStreamDefinitions()
          Define extra streams and also extra columns.
 void displayInternalInfo()
           
protected  void displayResultsTable()
           
protected  boolean findBackground()
          Count background pixels.
Should be called when only background have been segmented.
Not sure that this really makes sense, or I can assume that there is always 1 background.
protected  void findColorHypothesis()
          Everything related to setting the background color.
 IColorHypothesisFinder getColorHypothesisFinder()
           
 java.util.Map getContext()
           
 double getImageArea()
           
 java.lang.Integer getInputColor()
           
 java.lang.StringBuffer getInternalInfo()
           
 int getIterations()
           
 double getMaxDistance()
           
 int getMinPixelsInArea()
           
 RecursiveContext getParentContext()
           
 int getParticleCount()
           
 java.util.List<IColorAndVariance> getParticleFiltered()
           
 SBSegmentation getSegmentation()
           
 java.lang.String getStatus()
           
protected  void globalFilter()
          Filter particles on size and other global criteria.
protected  void init()
          Setup all the needed factory methods based on what type the image has.
 boolean isParticleImage()
          This is not fine tuned.
 boolean isUseReferenceAsBackground()
           
protected  void populateResultsTable()
          Populate the table with the streams.
protected  boolean populateResultsTableRow(int index)
          Populate one row of the result table with the default fields.
protected  void populateResultsTableRowCustom(int index)
          Populate one row of the result table with the extra fields.
 void run()
           
protected  void segment()
           
 void setColorHypothesisFinder(IColorHypothesisFinder colorHypothesisFinder)
           
 void setDisplayTable(boolean table)
           
 void setInputColor(java.lang.Integer color)
           
 void setIterations(int iterations)
           
 void setMaxDistance(double maxDistance)
           
 void setMinPixelsInArea(int minPixelsInArea)
           
 void setToMask(boolean toMask)
           
protected  void setupTableBuilder()
           
 void setUseReferenceAsBackground(boolean referenceAsBackground)
           
protected  void showResultDialog()
           
 
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
 
Methods inherited from interface org.shapelogic.imageutil.ImageOperation
getGuiWrapper, getImage, getKeyValueParser, getSetupReturnValue, isImageValid, setArg, setGuiWrapper, setKeyValueParser, setSetupReturnValue, setup, showAbout, showMessage
 

Field Detail

ITERATIONS_DEFAULTS

protected static final int ITERATIONS_DEFAULTS
See Also:
Constant Field Values

MAX_DISTANCE_DEFAULTS

protected static final double MAX_DISTANCE_DEFAULTS
See Also:
Constant Field Values

MIN_PIXELS_IN_AREA_DEFAULTS

protected static final int MIN_PIXELS_IN_AREA_DEFAULTS
See Also:
Constant Field Values

MAX_PIXELS_IN_AREA_DEFAULTS

protected static final int MAX_PIXELS_IN_AREA_DEFAULTS
See Also:
Constant Field Values

_particleImage

protected java.lang.Boolean _particleImage

_modifying

protected boolean _modifying
Modifying colors


_segmentation

protected SBSegmentation _segmentation

_saveArea

protected boolean _saveArea
Create a IColorAndVariance, area for each particle.


_colorHypothesisFinder

protected IColorHypothesisFinder _colorHypothesisFinder

_colorHypothesis

protected ColorHypothesis _colorHypothesis

_backgroundArea

protected int _backgroundArea

_backgroundCount

protected int _backgroundCount

_particleCount

protected java.lang.Integer _particleCount

_boundingBoxArea

protected double _boundingBoxArea

_iterations

protected int _iterations

_maxDistance

protected double _maxDistance

_minPixelsInArea

protected int _minPixelsInArea

_maxPixelsInArea

protected int _maxPixelsInArea

_displayTable

protected boolean _displayTable

_countOnly

protected boolean _countOnly

_toMask

protected boolean _toMask

_displayInternalInfo

protected boolean _displayInternalInfo

_particlesOrig

protected java.util.List<IColorAndVariance> _particlesOrig

_particlesFiltered

protected java.util.List<IColorAndVariance> _particlesFiltered

_categorizer

protected ListStream<java.lang.String> _categorizer

_inputColor

protected java.lang.Integer _inputColor

_backgroundColor

protected java.lang.Integer _backgroundColor

_referenceColor

protected java.lang.Integer _referenceColor

_useReferenceAsBackground

protected boolean _useReferenceAsBackground

_context

protected java.util.Map _context

_parentContext

protected RecursiveContext _parentContext

_paintForground

protected int _paintForground

_paintBackground

protected int _paintBackground
Constructor Detail

BaseParticleCounter

public BaseParticleCounter()
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

findColorHypothesis

protected void findColorHypothesis()
Everything related to setting the background color. TODO move all the set color stuff from segment() up her.


segment

protected void segment()

globalFilter

protected void globalFilter()
Filter particles on size and other global criteria.


defaultStreamDefinitions

protected void defaultStreamDefinitions()
Define extra streams and also extra columns.


customStreamDefinitions

protected void customStreamDefinitions()
Define extra streams and also extra columns.


setupTableBuilder

protected void setupTableBuilder()

categorizeStreams

protected void categorizeStreams()
Analyzes particles and group them.


defaultColumnDefinitions

protected void defaultColumnDefinitions()
Setup all the stream and other needed things.


populateResultsTable

protected void populateResultsTable()
Populate the table with the streams.


populateResultsTableRow

protected boolean populateResultsTableRow(int index)
Populate one row of the result table with the default fields.


populateResultsTableRowCustom

protected void populateResultsTableRowCustom(int index)
Populate one row of the result table with the extra fields.


displayResultsTable

protected void displayResultsTable()

showResultDialog

protected void showResultDialog()

displayInternalInfo

public void displayInternalInfo()

getInternalInfo

public java.lang.StringBuffer getInternalInfo()

init

protected void init()
             throws java.lang.Exception
Setup all the needed factory methods based on what type the image has.

Throws:
java.lang.Exception

getStatus

public java.lang.String getStatus()
Specified by:
getStatus in interface IParticleCounter

getSegmentation

public SBSegmentation getSegmentation()
Specified by:
getSegmentation in interface IParticleCounter

isParticleImage

public boolean isParticleImage()
This is not fine tuned.

Specified by:
isParticleImage in interface IParticleCounter

findBackground

protected boolean findBackground()
Count background pixels.
Should be called when only background have been segmented.
Not sure that this really makes sense, or I can assume that there is always 1 background.


getImageArea

public double getImageArea()

getParticleCount

public int getParticleCount()
Specified by:
getParticleCount in interface IParticleCounter

getParticleFiltered

public java.util.List<IColorAndVariance> getParticleFiltered()

getColorHypothesisFinder

public IColorHypothesisFinder getColorHypothesisFinder()
Specified by:
getColorHypothesisFinder in interface IParticleCounter

setColorHypothesisFinder

public void setColorHypothesisFinder(IColorHypothesisFinder colorHypothesisFinder)
Specified by:
setColorHypothesisFinder in interface IParticleCounter

getMaxDistance

public double getMaxDistance()
Specified by:
getMaxDistance in interface IParticleCounter

setMaxDistance

public void setMaxDistance(double maxDistance)
Specified by:
setMaxDistance in interface IParticleCounter

getMinPixelsInArea

public int getMinPixelsInArea()
Specified by:
getMinPixelsInArea in interface IParticleCounter

setMinPixelsInArea

public void setMinPixelsInArea(int minPixelsInArea)
Specified by:
setMinPixelsInArea in interface IParticleCounter

getIterations

public int getIterations()
Specified by:
getIterations in interface IParticleCounter

setIterations

public void setIterations(int iterations)
Specified by:
setIterations in interface IParticleCounter

setDisplayTable

public void setDisplayTable(boolean table)

getInputColor

public java.lang.Integer getInputColor()

setInputColor

public void setInputColor(java.lang.Integer color)

isUseReferenceAsBackground

public boolean isUseReferenceAsBackground()

setUseReferenceAsBackground

public void setUseReferenceAsBackground(boolean referenceAsBackground)

getContext

public java.util.Map getContext()
Specified by:
getContext in interface RecursiveContext

getParentContext

public RecursiveContext getParentContext()
Specified by:
getParentContext in interface RecursiveContext

setToMask

public void setToMask(boolean toMask)


Copyright © 2009. All Rights Reserved.