de.unihalle.informatik.MiToBo.morphology
Class ComponentPostprocess

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDOperator
      extended by de.unihalle.informatik.MiToBo.core.operator.MTBOperator
          extended by de.unihalle.informatik.MiToBo.morphology.ComponentPostprocess
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator, de.unihalle.informatik.Alida.operator.events.ALDOperatorExecutionProgressEventListener, EventListener

@ALDAOperator(genericExecutionMode=ALL,
              level=STANDARD)
@ALDMetaInfo(export=ALLOWED)
public class ComponentPostprocess
extends MTBOperator

Methods for post-processing components/pixels in binary images.

Thresholding algorithms yield binary images with distinct connected components of foreground pixels, i.e. regions. The routines of this class provide functionality for post-processing such binary (unlabeled) component images. Exemplary post-processing steps might include linking/merging adjacent components or changing a component's morphological shape.

Note that the different processing modes may require different parameter settings. These settings have to be done explicitly by calling the corresponding setter-functions the class provides. If the parameters are not set by the user default values are used.

Author:
moeller

Nested Class Summary
static class ComponentPostprocess.ProcessMode
          Processing mode identifiers.
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, operatorExecutionEventlistenerList, portHashAccess, verbose, versionProvider
 
Constructor Summary
ComponentPostprocess()
          Default constructor.
ComponentPostprocess(MTBImage img, ComponentPostprocess.ProcessMode pm)
          Default constructor.
ComponentPostprocess(MTBImage img, ComponentPostprocess.ProcessMode pm, int _minCompSize, int _maxCompDist, int maxVoroExpandDist)
          Deprecated.  
ComponentPostprocess(MTBImage img, ComponentPostprocess.ProcessMode pm, int _minCompSize, int _maxCompDist, int maxVoroExpandDist, double _roundnessThreshold)
          Deprecated.  
 
Method Summary
protected  MTBImageByte EraseLargeComponents(MTBImageByte binIP, int maxComponentSize)
          Function to remove large components from a binary image.
protected  MTBImageByte eraseNonCompactComponents(MTBImageByte binImage, double threshold)
          Function to remove all non compact/circular components of a binary image.
protected  MTBImageByte EraseRoundComponents(MTBImageByte binImage, double threshold)
          Remove components with small eccentricity.
protected  MTBImageByte EraseSmallComponents(MTBImageByte binIP, int minComponentSize)
          Function to remove small components from a binary image.
 double getCompactnessThreshold()
          Returns the actual value of compactness threshold.
 boolean getDiagonalNeighbors()
          Get value of Parameter argument DiagonalNeighbors.
 MTBImage getInputImage()
          Get reference to the current input image.
 int getMaximalComponentDist()
          Returns the maximal component distance for linking.
 int getMaximalComponentSize()
          Returns the maximal valid component size for component removal.
 int getMaxVoronoiExpandDist()
          Returns the maximal distance of pixels considered in Voronoi expansion.
 int getMinimalComponentSize()
          Returns the minimal valid component size for component removal.
 ComponentPostprocess.ProcessMode getProcessMode()
          Get current process mode.
 MTBImageByte getResultImage()
          Get the result image after applying operator.
 double getRoundnessThreshold()
          Returns the currently active roundness threshold.
protected  MTBImageByte LinkAdjacentComponents(MTBImageByte binIP)
          Function for linking adjacent components/regions in a binary image.
protected  MTBImageByte LinkAdjacentPixels(MTBImageByte binIP, int maxDist)
          Function for linking adjacent pixels in a binary image.
protected  void operate()
           
 void setCompactnessThreshold(double _compactnessTrheshold)
          Set the compactness threshold for eliminating non compact components.
 void setDiagonalNeighbors(boolean value)
          If true 8-neighborhood, i.e. diagonal neighbors, will be used in mode 'VORONOI_EXPAND' for Voronoi dilation.
 void setMaximalComponentDistance(int _maxCompDist)
          Set maximal component/pixel distance for linking.
 void setMaximalComponentSize(int _maxCompSize)
          Set maximal component size for erasing large components.
 void setMaximalVoronoiExpansionDistance(int _maxVoroExpandDist)
          Set radius of dilation mask in Voronoi expansion.
 void setMinimalComponentSize(int _minCompSize)
          Set minimal component size for erasing small components.
 void setRoundnessThreshold(double _roundnessThreshold)
          Set roundness threshold for eliminating round components.
protected  MTBImageByte VoronoiExpandComponents(MTBImageByte binImg, int maxDist)
          Dilate components, but avoid merges.
 
Methods inherited from class de.unihalle.informatik.MiToBo.core.operator.MTBOperator
readResolve
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
addOperatorExecutionProgressEventListener, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getHidingMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, runOp, runOp, runOp, setConstructionMode, setHidingMode, setName, setParameter, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentPostprocess

public ComponentPostprocess()
                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Default constructor.

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

ComponentPostprocess

public ComponentPostprocess(MTBImage img,
                            ComponentPostprocess.ProcessMode pm)
                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Default constructor.

Note that parameters for the chosen processing mode have to be set explicitly. Parameters for other modes are ignored.

Parameters:
img - Image to work on.
pm - Process mode of operator.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException -


ComponentPostprocess

@Deprecated
public ComponentPostprocess(MTBImage img,
                                       ComponentPostprocess.ProcessMode pm,
                                       int _minCompSize,
                                       int _maxCompDist,
                                       int maxVoroExpandDist)
                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Deprecated. 

Default constructor. A new empty meta data object is initialized.

Parameters:
img - Image to work on.
pm - Process mode of operator.
_minCompSize - Minimal region size for eliminating small comps.
_maxCompDist - Maximal region distance in linking.
maxVoroExpandDist - Max. distance of pixel considered in Voronoi expansion.

Note: Depending on the process mode each time only one of the parameters is actually in use.

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

ComponentPostprocess

@Deprecated
public ComponentPostprocess(MTBImage img,
                                       ComponentPostprocess.ProcessMode pm,
                                       int _minCompSize,
                                       int _maxCompDist,
                                       int maxVoroExpandDist,
                                       double _roundnessThreshold)
                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Deprecated. 

Default constructor. A new empty meta data object is initialized.

Parameters:
img -
pm - Process mode of operator.

_minCompSize -
_maxCompDist -
maxVoroExpandDist -
_roundnessThreshold -
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

setMinimalComponentSize

public void setMinimalComponentSize(int _minCompSize)
Set minimal component size for erasing small components.

Only used in mode 'ERASE_SMALL_COMPS'.

Parameters:
_minCompSize -

setMaximalComponentSize

public void setMaximalComponentSize(int _maxCompSize)
Set maximal component size for erasing large components.

Only used in mode 'ERASE_LARGE_COMPS'.


setMaximalComponentDistance

public void setMaximalComponentDistance(int _maxCompDist)
Set maximal component/pixel distance for linking.

Only used in modes 'LINK_ADJ_COMPS' and 'LINK_ADJ_PIXELS'.


setMaximalVoronoiExpansionDistance

public void setMaximalVoronoiExpansionDistance(int _maxVoroExpandDist)
Set radius of dilation mask in Voronoi expansion.

Only used in mode 'VORONOI_EXPAND'.

Parameters:
_maxVoroExpandDist -

setRoundnessThreshold

public void setRoundnessThreshold(double _roundnessThreshold)
Set roundness threshold for eliminating round components.

Only used in mode 'ERASE_ROUND_COMPS'.

Parameters:
_roundnessThreshold -

setCompactnessThreshold

public void setCompactnessThreshold(double _compactnessTrheshold)
Set the compactness threshold for eliminating non compact components.

Parameters:
_compactnessTrheshold -

setDiagonalNeighbors

public void setDiagonalNeighbors(boolean value)
If true 8-neighborhood, i.e. diagonal neighbors, will be used in mode 'VORONOI_EXPAND' for Voronoi dilation.

Parameters:
value -

getInputImage

public MTBImage getInputImage()
Get reference to the current input image.

Returns:
Input image to work on.

getProcessMode

public ComponentPostprocess.ProcessMode getProcessMode()
Get current process mode.

Returns:
Process mode of the component process.

getMinimalComponentSize

public int getMinimalComponentSize()
Returns the minimal valid component size for component removal.

Returns:

getMaximalComponentSize

public int getMaximalComponentSize()
Returns the maximal valid component size for component removal.

Returns:

getMaximalComponentDist

public int getMaximalComponentDist()
Returns the maximal component distance for linking.

Returns:

getMaxVoronoiExpandDist

public int getMaxVoronoiExpandDist()
Returns the maximal distance of pixels considered in Voronoi expansion.

Returns:

getDiagonalNeighbors

public boolean getDiagonalNeighbors()
Get value of Parameter argument DiagonalNeighbors.

Returns:
value of DiagonalNeighbors

getRoundnessThreshold

public double getRoundnessThreshold()
Returns the currently active roundness threshold.

Returns:

getCompactnessThreshold

public double getCompactnessThreshold()
Returns the actual value of compactness threshold.

Returns:

getResultImage

public MTBImageByte getResultImage()
Get the result image after applying operator. Attention, reference might be null.

Returns:
Reference to result image.

operate

protected void operate()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                       de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Specified by:
operate in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

EraseSmallComponents

protected MTBImageByte EraseSmallComponents(MTBImageByte binIP,
                                            int minComponentSize)
                                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                            de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Function to remove small components from a binary image.

Small components are components that have a size below the given threshold. Suitable for noise reduction in binary images.

Parameters:
binIP - binary input image
minComponentSize - minimum size of valid components
Returns:
image with too small components erased
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

EraseLargeComponents

protected MTBImageByte EraseLargeComponents(MTBImageByte binIP,
                                            int maxComponentSize)
                                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                            de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Function to remove large components from a binary image.

Large components are components that have a size above the given threshold.

Parameters:
binIP - binary input image
maxComponentSize - maximum size of valid components
Returns:
image with too large components erased
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

EraseRoundComponents

protected MTBImageByte EraseRoundComponents(MTBImageByte binImage,
                                            double threshold)
                                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                            de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Remove components with small eccentricity.

Parameters:
binImage - Input image.
threshold - Eccentricity threshold.
Returns:
Result image.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

eraseNonCompactComponents

protected MTBImageByte eraseNonCompactComponents(MTBImageByte binImage,
                                                 double threshold)
                                          throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                                 de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Function to remove all non compact/circular components of a binary image.

Parameters:
binImage - The input image.
threshold - The threshold of compactness
Returns:
A binary image with all regions removed who got a compactness less threshold
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

LinkAdjacentComponents

protected MTBImageByte LinkAdjacentComponents(MTBImageByte binIP)
                                       throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                              de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Function for linking adjacent components/regions in a binary image.

This function processes a binary image with foreground objects being white. Based on an initial component labeling step and subsequent skeletonization of resulting components, adjacent components are linked by a line of width one pixel in the result image.

The criterion for two components to be adjacent is defined based on the distance of pairs of skeleton endpoints of both components. If there exists at least one pair of endpoints between two components with a distance below the given threshold, the components are linked. If there is more than one pair of such points, the pair with the smallest distance is selected to be linked to each other.

Parameters:
binIP - input binary image with regions
Returns:
binary image where adjacent components are linked by a line of width 1 pixel
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

LinkAdjacentPixels

protected MTBImageByte LinkAdjacentPixels(MTBImageByte binIP,
                                          int maxDist)
                                   throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                          de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Function for linking adjacent pixels in a binary image.

This function processes a binary image containing only isolated pixels in the foreground. The foreground color is white. Based on the given maximal distance adjacent pixels are linked together to components. The result is comparable to a single-linkage clustering. As result an image is returned where adjacent pixels are linked to each other by a line of width one.

Note that the behaviour of the function is undefined if there are foreground objects present in the image other than single pixels!

Parameters:
binIP - input binary image with regions
maxDist -
Returns:
binary image where adjacent pixels are linked by a line of width 1 pixel
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException -

de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

VoronoiExpandComponents

protected MTBImageByte VoronoiExpandComponents(MTBImageByte binImg,
                                               int maxDist)
                                        throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                               de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Dilate components, but avoid merges.

Parameters:
binImg - Input image.
maxDist - Size of dilation mask.
Returns:
Result image.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException


Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.