de.unihalle.informatik.MiToBo.fields
Class GVFFieldCalculator2D

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

@ALDAOperator(genericExecutionMode=NONE,
              level=STANDARD)
public class GVFFieldCalculator2D
extends MTBOperator

Class to calculate a special 2D vector field, a Gradient Vector Flow Field (GVF) with its x- and y-flows from the given image. The GVF field is used as external energy in the snake calculation.

Author:
Danny Misiak

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  int height
          Size of the image and the calculated gvf field in y-direction.
private  MTBImage inputImage
          The input image as base for the GVF field calculation.
protected  double[] myX
          The flows of the field in x- and y-direction.
protected  double[] myY
          The flows of the field in x- and y-direction.
private  int numIterations
          Number of iterations for calculating the GVF field.
private  MTBImage.MTBImageType type
          Type of the input image and later the type of the calculated 2D vector field.
private  MTBVectorField2D vectorField
          The calculated GVF vector field.
private  int width
          Size of the image and the calculated gvf field in x-direction.
protected  double[] xFlow
          The flows of the field in x- and y-direction.
protected  double[] yFlow
          The flows of the field in x- and y-direction.
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
GVFFieldCalculator2D()
          Standard constructor.
GVFFieldCalculator2D(MTBImage inImg, int iterations)
          Constructor.
 
Method Summary
protected  double[] Abl_X(double[] values, int w, int h)
          Calculate the x-derivative of the gradient image.
protected  double[] Abl_Y(double[] values, int w, int h)
          Calculate the y-derivative of the gradient image.
protected  double[] BoundEnsure(double[] A, int w, int h)
          Test the image boundary.
protected  double[] BoundExpand(double[] A, int w, int h)
          Expand the image boundary.
protected  double[] BoundShrink(double[] A, int w, int h)
          Shrink the image boundary.
protected  void calcGVF()
          Calculate the GVF field with the given number of iterations on the given input image.
 int getHeight()
          Get image height.
 MTBImage getInputImage()
          Get input image.
 int getNumIterations()
          Get number of iterations for the GVF field.
 MTBImage.MTBImageType getType()
          Get input image type.
protected  double[] getValues()
          Get the double values of the given image.
 MTBVectorField2D getVectorField()
          Get calculated GVF vector field..
 int getWidth()
          Get image width.
protected  void normValues()
          Normalize the values in the gvf field in a range of [-1,1].
protected  void operate()
          This method does the actual work.
 void setHeight(int h)
          Set image height.
 void setInputImage(MTBImage inImg)
          Set input image.
 void setNumIterations(int iterations)
          Set number of iterations for the GVF field.
 void setWidth(int w)
          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

height

private transient int height
Size of the image and the calculated gvf field in y-direction.


inputImage

@Parameter(label="inputImage",
           required=true,
           direction=IN,
           description="Input image")
private transient MTBImage inputImage
The input image as base for the GVF field calculation.


myX

protected transient double[] myX
The flows of the field in x- and y-direction.


myY

protected transient double[] myY
The flows of the field in x- and y-direction.


numIterations

@Parameter(label="numIterations",
           required=true,
           direction=IN,
           description="Number of GVF field iterations")
private int numIterations
Number of iterations for calculating the GVF field.


type

private transient MTBImage.MTBImageType type
Type of the input image and later the type of the calculated 2D vector field.


vectorField

@Parameter(label="vectorField",
           required=true,
           direction=IN,
           description="Gradient vector field of the 2D image.")
private transient MTBVectorField2D vectorField
The calculated GVF vector field.


width

private transient int width
Size of the image and the calculated gvf field in x-direction.


xFlow

protected transient double[] xFlow
The flows of the field in x- and y-direction.


yFlow

protected transient double[] yFlow
The flows of the field in x- and y-direction.

Constructor Detail

GVFFieldCalculator2D

public GVFFieldCalculator2D()
                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Standard constructor. A new empty operator object is initialized.

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

GVFFieldCalculator2D

public GVFFieldCalculator2D(MTBImage inImg,
                            int iterations)
                     throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor. A new operator object is initialized.

Parameters:
inImg - image to work on
iterations - number of iterations for the gvf field
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

Abl_X

protected double[] Abl_X(double[] values,
                         int w,
                         int h)
Calculate the x-derivative of the gradient image.

Parameters:
values - gradient values of the image
w - width of the given image
h - height of the given image
Returns:
A one dimensional array including the x-derivative values

Abl_Y

protected double[] Abl_Y(double[] values,
                         int w,
                         int h)
Calculate the y-derivative of the gradient image.

Parameters:
values - gradient values of the image
w - width of the given image
h - height of the given image
Returns:
A one dimensional array including the y-derivative values

BoundEnsure

protected double[] BoundEnsure(double[] A,
                               int w,
                               int h)
Test the image boundary. It's necessary to calculate the derivatives in the border pixels of the image.

Parameters:
A - gradient image of the given image
w - width of the given image
h - height of the given image

BoundExpand

protected double[] BoundExpand(double[] A,
                               int w,
                               int h)
Expand the image boundary. It's necessary to calculate the derivatives in the border pixels of the image.

Parameters:
A - gradient image of the given image
w - width of the given image
h - height of the given image

BoundShrink

protected double[] BoundShrink(double[] A,
                               int w,
                               int h)
Shrink the image boundary. It's necessary to calculate the derivatives in the border pixels of the image.

Parameters:
A - gradient image of the given image
w - width of the given image
h - height of the given image

calcGVF

protected void calcGVF()
Calculate the GVF field with the given number of iterations on the given input image.


getHeight

public int getHeight()
Get image height.


getInputImage

public MTBImage getInputImage()
Get input image.


getNumIterations

public int getNumIterations()
Get number of iterations for the GVF field.


getType

public MTBImage.MTBImageType getType()
Get input image type.


getValues

protected double[] getValues()
Get the double values of the given image.

Returns:
Double values of the given image in a one dimensional double array.

getVectorField

public MTBVectorField2D getVectorField()
Get calculated GVF vector field..


getWidth

public int getWidth()
Get image width.


normValues

protected void normValues()
Normalize the values in the gvf field in a range of [-1,1].


operate

protected void operate()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
This method does the actual work. Each subclass needs to overwrite this method. As parameter a MiToBo parameter object is passed to the function where all required data and operator configuration information can be found.

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

setHeight

public void setHeight(int h)
Set image height.


setInputImage

public void setInputImage(MTBImage inImg)
Set input image.


setNumIterations

public void setNumIterations(int iterations)
Set number of iterations for the GVF field.


setWidth

public void setWidth(int w)
Set image width.