de.unihalle.informatik.MiToBo.segmentation.contours.extraction
Class ContourOnLabeledComponents

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.contours.extraction.ContourOnLabeledComponents
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator, de.unihalle.informatik.Alida.operator.events.ALDOperatorExecutionProgressEventListener, EventListener

@ALDAOperator(genericExecutionMode=ALL,
              level=APPLICATION)
public class ContourOnLabeledComponents
extends MTBOperator

Class to segment contours from a binary image using the contour following algorithm. The contours are only segmented from a set of given image regions in this binary image. If no image regions exist you should use one of the LabelComponent methods from the package de.unihalle.informatik.MiToBo.segmentation.regions.labeling.

Outer contours as well as inner contours (length greater than a given value) are segmented.

Author:
Danny Misiak

Nested Class Summary
static class ContourOnLabeledComponents.ContourType
          The possible type of contours for segmentation.
 
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
ContourOnLabeledComponents()
          Standard constructor.
ContourOnLabeledComponents(MTBImageByte inImg, MTBRegion2DSet inRegions, ContourOnLabeledComponents.ContourType type, int length)
          Constructor.
ContourOnLabeledComponents(MTBRegion2DSet inRegions, ContourOnLabeledComponents.ContourType type, int length)
          Constructor.
 
Method Summary
protected  MTBContour2DSet addInnerContours()
          Adding the possible inner contours to the outer contour of a region.
protected  MTBImageByte calcContours()
          Get all inner- and outer-contours for the given regions.
protected  int findNextPoint(Point2D.Double Xc, int dir, MTBImageByte theImage)
          Find direction to next pixel in specific direction from the last pixel.
 ContourOnLabeledComponents.ContourType getContourType()
          Get reference to the current contour type.
 int getHeight()
          Get image height.
 int getInnerContourLengthMin()
          Get the minimum number of pixels in the inner contour (length of the contour).
 MTBImageByte getInputImage()
          Get reference to the current input image.
 MTBRegion2DSet getInputRegions()
          Get reference to the input regions.
protected  MTBContour2DSet getOuterContours(MTBRegion2DSet theRegions, MTBImageByte theImage)
          Calculate the outer contours of the given regions in a image.
 MTBContour2DSet getResultContours()
          Get reference to the calculated contours.
 MTBImageByte getResultImage()
          Get reference to the binary image with the calculated contours.
 int getWidth()
          Get image width.
protected  void operate()
          This method does the actual work.
 void setContourType(ContourOnLabeledComponents.ContourType type)
          Set reference to the contour type.
 void setHeight(int h)
          Set image height.
 void setInnerContourLengthMin(int length)
          Set the minimum number of pixels in the inner contour (length of the contour).
 void setInputImage(MTBImageByte inImg)
          Set reference to the current input image.
 void setInputRegions(MTBRegion2DSet inRegions)
          Set reference to the the input regions.
 void setWidth(int w)
          Set image width.
protected  MTBImageByte toMTBImageByte()
          Method to save all contours from the regions on a binary image with specific width and height.
protected  MTBContour2D traceContour(int xS, int yS, MTBImageByte theImage)
          Trace contour, starting at (xS, yS) in direction dS.
 
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

ContourOnLabeledComponents

public ContourOnLabeledComponents()
                           throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Standard constructor.

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

ContourOnLabeledComponents

public ContourOnLabeledComponents(MTBImageByte inImg,
                                  MTBRegion2DSet inRegions,
                                  ContourOnLabeledComponents.ContourType type,
                                  int length)
                           throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor. A new operator object is initialized.

Parameters:
inImg - input image to work on
inRegions - regions to get the contours from
type - type of the resulting contour regions to get the contours from
length - minimum number of pixels that a inner region must have (length of the inner contour) to calculate the inner contour
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

ContourOnLabeledComponents

public ContourOnLabeledComponents(MTBRegion2DSet inRegions,
                                  ContourOnLabeledComponents.ContourType type,
                                  int length)
                           throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor. A new operator object is initialized. No labeled image is give, so for each region the binary image is calculated for contour following.

Parameters:
inRegions - regions to get the contours from
type - type of the resulting contour regions to get the contours from
length - minimum number of pixels that a inner region must have (length of the inner contour) to calculate the inner contour
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

getInputImage

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

Returns:
Input image to work on.

setInputImage

public void setInputImage(MTBImageByte inImg)
Set reference to the current input image.


getInputRegions

public MTBRegion2DSet getInputRegions()
Get reference to the input regions.

Returns:
Region2D vector including all regions.

setInputRegions

public void setInputRegions(MTBRegion2DSet inRegions)
Set reference to the the input regions.


getContourType

public ContourOnLabeledComponents.ContourType getContourType()
Get reference to the current contour type.

Returns:
The used contour type.

setContourType

public void setContourType(ContourOnLabeledComponents.ContourType type)
Set reference to the contour type.


getInnerContourLengthMin

public int getInnerContourLengthMin()
Get the minimum number of pixels in the inner contour (length of the contour). No inner contours with a length below this value will be segmented.

Returns:
Minimum value of pixels for a inner region.

setInnerContourLengthMin

public void setInnerContourLengthMin(int length)
Set the minimum number of pixels in the inner contour (length of the contour). No inner contours with a length below this value will be segmented.


getResultImage

public MTBImageByte getResultImage()
Get reference to the binary image with the calculated contours.

Returns:
Binary image with contours

getResultContours

public MTBContour2DSet getResultContours()
Get reference to the calculated contours.

Returns:
Inner- and outer-contours of the regions.

getWidth

public int getWidth()
Get image width.


setWidth

public void setWidth(int w)
Set image width.


getHeight

public int getHeight()
Get image height.


setHeight

public void setHeight(int h)
Set image height.


operate

protected void operate()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                       de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
This method does the actual work.

Specified by:
operate in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

calcContours

protected MTBImageByte calcContours()
                             throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                    de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Get all inner- and outer-contours for the given regions.

Returns:
Image including all contours that should be segmented.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

addInnerContours

protected MTBContour2DSet addInnerContours()
                                    throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                           de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Adding the possible inner contours to the outer contour of a region.

Returns:
Vector including all inner contours of a outer contour.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

getOuterContours

protected MTBContour2DSet getOuterContours(MTBRegion2DSet theRegions,
                                           MTBImageByte theImage)
Calculate the outer contours of the given regions in a image. Method from the book: W. Burger, M.J. Burge, "Digitale Bildverarbeitung. Eine Einfuehrung mit Java und ImageJ.", page 211

Parameters:
theRegions - Regions to get contours from.
theImage - Binary image of the regions to get the contours from.
Returns:
Vector of contours from the given regions.

traceContour

protected MTBContour2D traceContour(int xS,
                                    int yS,
                                    MTBImageByte theImage)
Trace contour, starting at (xS, yS) in direction dS.

Parameters:
xS - starting x-coordinate
yS - starting y-coordinate
theImage - the binary image to validate if pixel is black or white (get the label)
Returns:
Contour of the region.

findNextPoint

protected int findNextPoint(Point2D.Double Xc,
                            int dir,
                            MTBImageByte theImage)
Find direction to next pixel in specific direction from the last pixel.

Parameters:
Xc - starting point
dir - direction of last point
theImage - the binary image to validate if pixel is black or white (get the label)
Returns:
Next direction.

toMTBImageByte

protected MTBImageByte toMTBImageByte()
Method to save all contours from the regions on a binary image with specific width and height.

Returns:
2D inner- and outer-contours in a binary image of type MTBImageByte.


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