de.unihalle.informatik.MiToBo.morphology
Class DistanceTransform

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.DistanceTransform
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator

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

 
 Class to calculate a distance map / field from a binary image using the
 Champfer-algorithm from
 
 G. Borgefors, “Distance transformations in digital images,” Computer
 Vision, Graphics, and Image Processing, vol. 34, pp. 344–371, 1986.
 
 Several distance metrics (Euclide, Chessboard, Cityblock) and the foreground
 (0 for black and 1 for white) can be specified. A 8-way neighborhood is used.
 
 The distance field is created as MTBImage or as a two dimensional double array.
 First dimension specifies the y-coordinate of the field, and the
 second dimension specifies the x-coordinate of the field.
 
 

Author:
misiak

Nested Class Summary
static class DistanceTransform.DistanceMetric
          Several distance metrics.
static class DistanceTransform.ForegroundColor
          Color of binary image foreground.
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
private  MTBImage distanceImg
          The distance field as MTBImage.
private  double[][] distanceMap
          The distance field as two-dimensional double array.
private  DistanceTransform.DistanceMetric distanceMetric
           
private  DistanceTransform.ForegroundColor foreground
          Foreground color of the foreground object.
private  int height
          Width and height of the given image.
private  MTBImageByte inputImage
           
private  int width
          Width and height of the given image.
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
DistanceTransform()
          Standard constructor.
DistanceTransform(MTBImageByte image, DistanceTransform.DistanceMetric dm, DistanceTransform.ForegroundColor fg)
          Constructor to create a new DistanceTransform object.
 
Method Summary
private  void calcDM()
          Method to calculate the distance map of the given binary image using the Chamfer-algorithm.
 MTBImage getDistanceImage()
          Get the calculated distance map image.
 double[][] getDistanceMap()
          Get the calculated distance map.
 DistanceTransform.DistanceMetric getDistMetric()
          Get the used distance metric.
 DistanceTransform.ForegroundColor getForeground()
          Get the used foreground color.
 int getHeight()
          Get image height.
 MTBImageByte getInImg()
          Get the input image.
 int getWidth()
          Get image width.
protected  void operate()
           
 void setDistMetric(DistanceTransform.DistanceMetric metric)
          Set the distance metric.
 void setForeground(DistanceTransform.ForegroundColor fColor)
          Set the foreground color.
 void setHeight(int height)
          Set image height.
 void setInImg(MTBImageByte inImg)
          Set the input image.
 void setWidth(int width)
          Set image width.
 
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

distanceImg

@Parameter(label="Distance Map Image",
           direction=OUT,
           description="Image of the distance map.")
private transient MTBImage distanceImg
The distance field as MTBImage.


distanceMap

@Parameter(label="Distance Map",
           direction=OUT,
           description="2D distance map array.")
private double[][] distanceMap
The distance field as two-dimensional double array. Organized as double[y-dimension][x-dimension].


distanceMetric

@Parameter(label="Distance Metric",
           direction=IN,
           required=true,
           description="Used distance metric",
           mode=STANDARD,
           dataIOOrder=1)
private DistanceTransform.DistanceMetric distanceMetric

foreground

@Parameter(label="Foreground Color",
           required=true,
           direction=IN,
           description="Color of foreground.",
           mode=STANDARD,
           dataIOOrder=2)
private DistanceTransform.ForegroundColor foreground
Foreground color of the foreground object.


height

private int height
Width and height of the given image.


inputImage

@Parameter(label="Binary Input Image",
           required=true,
           direction=IN,
           description="Binary input image.",
           mode=STANDARD,
           dataIOOrder=0)
private transient MTBImageByte inputImage

width

private int width
Width and height of the given image.

Constructor Detail

DistanceTransform

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

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

DistanceTransform

public DistanceTransform(MTBImageByte image,
                         DistanceTransform.DistanceMetric dm,
                         DistanceTransform.ForegroundColor fg)
                  throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor to create a new DistanceTransform object.

Parameters:
image - the input image to calculate the distance map on it
dm - the distance metric
fg - set foreground white or black
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

calcDM

private void calcDM()
Method to calculate the distance map of the given binary image using the Chamfer-algorithm. A specified distance metric and the fore- and background of the binary image can be chosen. A neighborhood of 8 is used for the distance calculation.


getDistanceImage

public MTBImage getDistanceImage()
Get the calculated distance map image.

Returns:
Distance map image.

getDistanceMap

public double[][] getDistanceMap()
Get the calculated distance map. First dimension specifies the y-coordinate of the field, and the second dimension specifies the x-coordinate of the field.

Returns:
Distance map.

getDistMetric

public DistanceTransform.DistanceMetric getDistMetric()
Get the used distance metric.

Returns:
Distance metric.

getForeground

public DistanceTransform.ForegroundColor getForeground()
Get the used foreground color.

Returns:
Foreground color.

getHeight

public int getHeight()
Get image height.


getInImg

public MTBImageByte getInImg()
Get the input image.

Returns:
Input image.

getWidth

public int getWidth()
Get image width.


operate

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

setDistMetric

public void setDistMetric(DistanceTransform.DistanceMetric metric)
Set the distance metric.


setForeground

public void setForeground(DistanceTransform.ForegroundColor fColor)
Set the foreground color.


setHeight

public void setHeight(int height)
Set image height.


setInImg

public void setInImg(MTBImageByte inImg)
Set the input image.


setWidth

public void setWidth(int width)
Set image width.