de.unihalle.informatik.MiToBo.segmentation.regions.labeling
Class LabelComponentsSequential

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.segmentation.regions.labeling.LabelComponentsSequential
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator

@ALDAOperator(genericExecutionMode=ALL,
              level=STANDARD)
public class LabelComponentsSequential
extends MTBOperator

Sequential component labeling for binarized 2D images to find connected components. Foreground pixels are assumed to have a value > 0, all pixels with value <= 0 are assumed to be background. Algorithm:
W. Burger and M. Burge, Digital image processing: an algorithmic introduction using Java, 2008, Springer-Verlag New York Inc

Author:
gress

Nested Class Summary
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
private  MTBImage colorImage
           
private  java.lang.Boolean createColorImage
           
private  java.lang.Boolean createLabelImage
           
private  boolean diagonalNeighbors
           
private  MTBImage inputImage
           
private  MTBImage labelImage
           
private  int m_height
           
private  MTBImageInt m_labelImg
           
private  int m_width
           
private  MTBRegion2DSet resultingRegions
           
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
LabelComponentsSequential()
          Constructor
LabelComponentsSequential(MTBImage img, boolean diagonalNeighbors)
          Constructor
 
Method Summary
 MTBImage getColorImage()
          Get image of randomly colored regions, if the create-color-image-flag was set to true.
 boolean getCreateColorImageFlag()
          Get the flag that determines the creation of an image with randomly colored regions.
 boolean getCreateLabelImageFlag()
          Get the flag that determines the creation of an image with region labels.
 boolean getDiagonalNeighborsFlag()
          Get the neighborhood flag.
 MTBImage getInputImage()
          Get reference to the current input image.
private  int getLabel(int x, int y)
          returns the value of labelImg at position (x,y).
 MTBImage getLabelImage()
          Get image of region labels (of type MTB_INT), if the create-label-image-flag was set to true.
 MTBRegion2DSet getResultingRegions()
          Get the resulting regions.
protected  MTBRegion2DSet labelComponents(MTBImage img, boolean diagonalNeighbors)
          Sequential component labeling
protected  void operate()
           
protected  void setColorImage(MTBImage colorImage)
          Add the label image to the parameter object
 void setCreateColorImageFlag(boolean createColorImage)
          Set the flag that determines the creation of an image with randomly colored regions.
 void setCreateLabelImageFlag(boolean createLabelImage)
          Set the flag that determines the creation of an image with region labels.
 void setDiagonalNeighborsFlag(boolean diagonalNeighbors)
          Set the neighborhood flag.
 void setInputImage(MTBImage inputImage)
          Set a new input image.
protected  void setLabelImage(MTBImage labelImage)
          Set image of region labels
protected  void setResultingRegions(MTBRegion2DSet regions)
          Attach the vector of resulting regions.
 
Methods inherited from class de.unihalle.informatik.MiToBo.core.operator.MTBOperator
readResolve
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
deserializeFromXmlFile, fieldContained, getALDPortHashAccessKey, getConstructionMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, isConfigured, parametersToXmlObject, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, runOp, runOp, runOp, serializeToXmlFile, setConstructionMode, setName, setParameter, setParametersFromXml, setParametersFromXml, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory, writeParametersToXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorImage

@Parameter(label="Color image",
           required=false,
           direction=OUT,
           dataIOOrder=3,
           description="Image of regions with random colors")
private transient MTBImage colorImage

createColorImage

@Parameter(label="Create color image",
           required=true,
           direction=IN,
           dataIOOrder=4,
           mode=STANDARD,
           description="Create image of regions with random colors")
private java.lang.Boolean createColorImage

createLabelImage

@Parameter(label="Create label image",
           required=true,
           direction=IN,
           dataIOOrder=3,
           mode=STANDARD,
           description="Create image of regions with region labels")
private java.lang.Boolean createLabelImage

diagonalNeighbors

@Parameter(label="Diagonal neighborhood",
           required=true,
           direction=IN,
           dataIOOrder=2,
           mode=STANDARD,
           description="true for 8-neighborhood, false for 4-neighborhood")
private boolean diagonalNeighbors

inputImage

@Parameter(label="Input image",
           required=true,
           direction=IN,
           dataIOOrder=1,
           mode=STANDARD,
           description="Input image")
private transient MTBImage inputImage

labelImage

@Parameter(label="Label image",
           required=false,
           direction=OUT,
           dataIOOrder=2,
           description="Image of regions with labels (MTBImageType.MTB_INT)")
private transient MTBImage labelImage

m_height

private int m_height

m_labelImg

private MTBImageInt m_labelImg

m_width

private int m_width

resultingRegions

@Parameter(label="Resulting regions",
           required=true,
           direction=OUT,
           dataIOOrder=1,
           description="Resulting regions")
private MTBRegion2DSet resultingRegions
Constructor Detail

LabelComponentsSequential

public LabelComponentsSequential()
                          throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor

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

LabelComponentsSequential

public LabelComponentsSequential(MTBImage img,
                                 boolean diagonalNeighbors)
                          throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor

Parameters:
img - input image
diagonalNeighbors - set true for 8-neighborhood or false for 4-neighborhood
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

getColorImage

public MTBImage getColorImage()
Get image of randomly colored regions, if the create-color-image-flag was set to true. Otherwise returns null.


getCreateColorImageFlag

public boolean getCreateColorImageFlag()
Get the flag that determines the creation of an image with randomly colored regions.


getCreateLabelImageFlag

public boolean getCreateLabelImageFlag()
Get the flag that determines the creation of an image with region labels.


getDiagonalNeighborsFlag

public boolean getDiagonalNeighborsFlag()
Get the neighborhood flag.

Returns:
true if 8-neighborhood is used, false if 4-neighborhood is used

getInputImage

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

Returns:
Input image to work on.

getLabel

private int getLabel(int x,
                     int y)
returns the value of labelImg at position (x,y). Also checks for image boundaries, returns 0 when (x,y) is outside of the image

Parameters:
x - x-coordinate
y - y-coordinate
labelImg - actual label image
Returns:
pixel value at (x,y) if (x,y) inside the image. If outside of the image, returns 0

getLabelImage

public MTBImage getLabelImage()
Get image of region labels (of type MTB_INT), if the create-label-image-flag was set to true. Otherwise returns null.


getResultingRegions

public MTBRegion2DSet getResultingRegions()
Get the resulting regions.


labelComponents

protected MTBRegion2DSet labelComponents(MTBImage img,
                                         boolean diagonalNeighbors)
Sequential component labeling

Parameters:
img - (binary) input image
diagonalNeighbors - set true for 8-neighborhood components, set false for 4-neighborhood
Returns:
returns a vector of regions

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

setColorImage

protected void setColorImage(MTBImage colorImage)
Add the label image to the parameter object


setCreateColorImageFlag

public void setCreateColorImageFlag(boolean createColorImage)
Set the flag that determines the creation of an image with randomly colored regions.


setCreateLabelImageFlag

public void setCreateLabelImageFlag(boolean createLabelImage)
Set the flag that determines the creation of an image with region labels.


setDiagonalNeighborsFlag

public void setDiagonalNeighborsFlag(boolean diagonalNeighbors)
Set the neighborhood flag.

Parameters:
diagonalNeighbors - set true for 8-neighborhood and false for 4-neighborhood

setInputImage

public void setInputImage(MTBImage inputImage)
Set a new input image.


setLabelImage

protected void setLabelImage(MTBImage labelImage)
Set image of region labels


setResultingRegions

protected void setResultingRegions(MTBRegion2DSet regions)
Attach the vector of resulting regions.