de.unihalle.informatik.MiToBo.segmentation.snakes.energies
Class MTBSnakeEnergyCDImageBased

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.segmentation.snakes.energies.MTBSnakeEnergyCDImageBased
All Implemented Interfaces:
MTBActiveContourEnergyDerivable, MTBSnakeEnergyComputable, MTBSnakeEnergyDerivable
Direct Known Subclasses:
MTBSnakeEnergyCDIB_Distance, MTBSnakeEnergyCDIB_Gradient, MTBSnakeEnergyCDIB_GVF2D, MTBSnakeEnergyCDIB_Intensity

@ALDParametrizedClass
public abstract class MTBSnakeEnergyCDImageBased
extends java.lang.Object
implements MTBSnakeEnergyDerivable, MTBSnakeEnergyComputable

Interface class for snake energies that are pure image-based.

This class is used by the snake optimizer. Pure image-based energies are energies that just evaluate the energy gradient at single image positions. Examples are intensity gradient, GVFs and so on. On updating the snake optimizer target functional they usually just modify the constant vector and not the linear matrix. All energies of this type share the common property that derivatives can be calculated quite easy and straight-forward which separates them from more complex snake energies.

Author:
moeller

Field Summary
protected  int height
          Height of the given image for the energy.
protected  double normalizationFactor
          Normalization factor for scaling matrix entries.
protected  SnakeOptimizerSingle.EnergyNormalizationMode normMode
          Mode of normalization.
protected  double scaleFactor
          Scaling factor to rescale image coordinates in range [0,1] or several ranges to the original coordinates range like [1000, 1000] in a image of size 1000 x 1000.
protected  int width
          Width of the given image for the energy.
 
Fields inherited from interface de.unihalle.informatik.MiToBo.segmentation.snakes.energies.MTBSnakeEnergyDerivable
targetEnergyRange
 
Constructor Summary
MTBSnakeEnergyCDImageBased()
           
 
Method Summary
 double calcEnergy(SnakeOptimizerSingle opt)
          Calculates the energy of the current snake.
 double calcEnergy(SnakeOptimizerSingle opt, int pointID)
           
 Jama.Matrix getDerivative_MatrixPart(SnakeOptimizerSingleVarCalc opt)
          Returns the linear matrix part of this energy for snake optimization.
 Jama.Matrix getDerivative_VectorPart(SnakeOptimizerSingleVarCalc opt)
          Returns the vector part of this energy for snake optimization.
 double getDerivativeX_norm(double x, double y)
          Get x-derivative of external snake energy at given position on a normalizes image coordinates in range [width*scale, height*scale].
abstract  double getDerivativeX(double x, double y)
          Get x-derivative of external snake energy at given position.
 double getDerivativeY_norm(double x, double y)
          Get y-derivative of external snake energy at given position on a normalizes image coordinates in range [width*scale, height*scale].
abstract  double getDerivativeY(double x, double y)
          Get y-derivative of external snake energy at given position.
 double getScaleFactor()
          Get scaling factor.
 double getValue_norm(double x, double y)
          Returns the value of the external energy at the given position on a normalizes image coordinates in range [width*scale, height*scale].
abstract  double getValue(double x, double y)
          Returns the value of the external energy at the given position.
 boolean initEnergy(SnakeOptimizerSingleGreedy o)
          Init routine which is called once before the energy is actually used.
 boolean initEnergy(SnakeOptimizerSingleVarCalc o)
          Init routine which is called once before the energy is actually used.
protected abstract  void normalizeEnergy()
          Normalize the external energy in a range [-1.0, 1.0].
 void setScaleFactor(double s)
          Set the scaling factor.
 void updateStatus(SnakeOptimizerSingleGreedy o)
          Update internal state of energy object prior to querying derivatives and so on.
 void updateStatus(SnakeOptimizerSingleVarCalc o)
          Update internal state of energy object prior to usaging it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.unihalle.informatik.MiToBo.segmentation.snakes.energies.MTBSnakeEnergyDerivable
toString
 
Methods inherited from interface de.unihalle.informatik.MiToBo.segmentation.snakes.energies.MTBSnakeEnergyComputable
toString
 

Field Detail

height

protected int height
Height of the given image for the energy.


normalizationFactor

protected double normalizationFactor
Normalization factor for scaling matrix entries.


normMode

protected SnakeOptimizerSingle.EnergyNormalizationMode normMode
Mode of normalization.


scaleFactor

protected double scaleFactor
Scaling factor to rescale image coordinates in range [0,1] or several ranges to the original coordinates range like [1000, 1000] in a image of size 1000 x 1000. Default scaling factor is 1.


width

protected int width
Width of the given image for the energy.

Constructor Detail

MTBSnakeEnergyCDImageBased

public MTBSnakeEnergyCDImageBased()
Method Detail

calcEnergy

public double calcEnergy(SnakeOptimizerSingle opt)
Description copied from interface: MTBSnakeEnergyComputable
Calculates the energy of the current snake.

Specified by:
calcEnergy in interface MTBSnakeEnergyComputable
Parameters:
opt - Calling snake optimizer.
Returns:
Energy of complete snake.

calcEnergy

public double calcEnergy(SnakeOptimizerSingle opt,
                         int pointID)

getDerivative_MatrixPart

public final Jama.Matrix getDerivative_MatrixPart(SnakeOptimizerSingleVarCalc opt)
Description copied from interface: MTBSnakeEnergyDerivable
Returns the linear matrix part of this energy for snake optimization.

Specified by:
getDerivative_MatrixPart in interface MTBSnakeEnergyDerivable
Parameters:
opt - Calling snake optimizer.
Returns:
Optimization matrix for this energy object.

getDerivative_VectorPart

public Jama.Matrix getDerivative_VectorPart(SnakeOptimizerSingleVarCalc opt)
Description copied from interface: MTBSnakeEnergyDerivable
Returns the vector part of this energy for snake optimization.

Specified by:
getDerivative_VectorPart in interface MTBSnakeEnergyDerivable
Parameters:
opt - Calling snake optimizer.
Returns:
Optimization vector for this energy object.

getDerivativeX_norm

public double getDerivativeX_norm(double x,
                                  double y)
Get x-derivative of external snake energy at given position on a normalizes image coordinates in range [width*scale, height*scale].

Parameters:
x - x-coordinate of position
y - y-coordinate of position
Returns:
x-derivative value at given scaled position.

getDerivativeX

public abstract double getDerivativeX(double x,
                                      double y)
Get x-derivative of external snake energy at given position.

Parameters:
x - x-coordinate of pixel position
y - y-coordinate of pixel position
Returns:
x-derivative value at given position.

getDerivativeY_norm

public double getDerivativeY_norm(double x,
                                  double y)
Get y-derivative of external snake energy at given position on a normalizes image coordinates in range [width*scale, height*scale].

Parameters:
x - x-coordinate of position
y - y-coordinate of position
Returns:
y-derivative value at given scaled position.

getDerivativeY

public abstract double getDerivativeY(double x,
                                      double y)
Get y-derivative of external snake energy at given position.

Parameters:
x - x-coordinate of pixel position
y - y-coordinate of pixel position
Returns:
y-derivative value at given position.

getScaleFactor

public double getScaleFactor()
Get scaling factor.

Specified by:
getScaleFactor in interface MTBSnakeEnergyComputable
Specified by:
getScaleFactor in interface MTBSnakeEnergyDerivable
Returns:
Scaling factor.

getValue_norm

public double getValue_norm(double x,
                            double y)
Returns the value of the external energy at the given position on a normalizes image coordinates in range [width*scale, height*scale].

Parameters:
x - x-coordinate of position
y - y-coordinate of position
Returns:
Absolute value of external energy.

getValue

public abstract double getValue(double x,
                                double y)
Returns the value of the external energy at the given position.

Parameters:
x - x-coordinate of position
y - y-coordinate of position
Returns:
Absolute value of external energy.

initEnergy

public boolean initEnergy(SnakeOptimizerSingleGreedy o)
Description copied from interface: MTBSnakeEnergyComputable
Init routine which is called once before the energy is actually used.

In this routine global parameter settings can be handled or other initialization stuff be done. The SnakeOptimizer will call this routine once before the actual use of the energy. If no stuff needs to be done in advance the routine should at least return true.

Specified by:
initEnergy in interface MTBSnakeEnergyComputable
Parameters:
o - Calling snake optimizer.
Returns:
true if init was successful

initEnergy

public boolean initEnergy(SnakeOptimizerSingleVarCalc o)
Description copied from interface: MTBSnakeEnergyDerivable
Init routine which is called once before the energy is actually used.

In this routine global parameter settings can be handled or other initialization stuff be done. The SnakeOptimizer will call this routine once before the actual use of the energy. If no stuff needs to be done in advance the routine should at least return true.

Specified by:
initEnergy in interface MTBSnakeEnergyDerivable
Parameters:
o - Calling snake optimizer.
Returns:
True if init was successful, otherwise false.

normalizeEnergy

protected abstract void normalizeEnergy()
Normalize the external energy in a range [-1.0, 1.0]. The user implements how the energy is normalized. The range can also be [0.0, 1.0] or something else, but the range must be inside [-1.0, 1.0]. The normalization is called in the initEnergy method of the energy.


setScaleFactor

public void setScaleFactor(double s)
Set the scaling factor.

Specified by:
setScaleFactor in interface MTBSnakeEnergyComputable
Specified by:
setScaleFactor in interface MTBSnakeEnergyDerivable
Parameters:
s - new scaling factor.

updateStatus

public void updateStatus(SnakeOptimizerSingleGreedy o)
Description copied from interface: MTBSnakeEnergyComputable
Update internal state of energy object prior to querying derivatives and so on.

Specified by:
updateStatus in interface MTBSnakeEnergyComputable

updateStatus

public void updateStatus(SnakeOptimizerSingleVarCalc o)
Description copied from interface: MTBSnakeEnergyDerivable
Update internal state of energy object prior to usaging it.

Specified by:
updateStatus in interface MTBSnakeEnergyDerivable