de.unihalle.informatik.MiToBo.tools.image
Class ImageValueTools

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

@ALDAOperator(genericExecutionMode=NONE)
public class ImageValueTools
extends MTBOperator

An operator class for different simple operations on the values of an image like inversion, filling with a constant value, etc.

The policy here is to use static functions instead of constructing a new object, set its parameters and then call runOp(). Thus the source code is reduced as the functions of this class are assumed to be called quite often.

This class is meant to implement convenience functions on images to keep the image classes from bloating. Feel free to extend this class with your convenience functions. Please implement static methods for any functionality to keep the policy of this class. Be aware that the input image is changed, i.e. the input image is also the result image. (You don't need to get the result image, if you still have a reference to the input image, but this method is implemented for completeness)

Author:
Oliver Gress

Nested Class Summary
static class ImageValueTools.ImageValueModification
          Available image value modification methods.
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
private  double fromMaxVal
           
private  double fromMinVal
           
private  java.lang.Double grayValue
           
private  MTBImage inputImage
           
private  double lowerBound
           
private  ImageValueTools.ImageValueModification modificationMode
           
private  MTBImage resultImage
           
private  java.awt.Color rgbValue
           
private  double upperBound
           
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
  ImageValueTools()
           
protected ImageValueTools(MTBImage img)
          Constructor.
 
Method Summary
protected  void fill(MTBImage img, java.awt.Color rgbvalue)
           
protected  void fill(MTBImage img, double grayvalue)
           
static void fillImage(MTBImage img, java.awt.Color rgbvalue, MTBOperator callingOperator)
          Fill the image with a RGB color value.
static void fillImage(MTBImage img, double grayvalue, MTBOperator callingOperator)
          Fill the specified image with a gray value.
protected  java.lang.Double getGrayValue()
           
 MTBImage getInputImage()
           
protected  double getLowerBound()
          Get lower bound of the normalization to range [lowerBound, upperBound].
protected  ImageValueTools.ImageValueModification getModification()
           
 MTBImage getResultImage()
           
protected  java.awt.Color getRGBValue()
           
protected  double getUpperBound()
          Get upper bound of the normalization to range [lowerBound, upperBound].
protected  void invert(MTBImage img)
           
static void invertImage(MTBImage img, MTBOperator callingOperator)
          Invert the specified image.
protected  void normFromTo(MTBImage img)
           
static void normImageFromTo(MTBImage img, double oldMinVal, double oldMaxVal, double newMinVal, double newMaxVal, MTBOperator callingOperator)
          Normalize the image values to range [lowerBound, upperBound].
static void normImageTo(MTBImage img, double lowerBound, double upperBound, MTBOperator callingOperator)
          Normalize the image values to range [lowerBound, upperBound].
protected  void normTo(MTBImage img, double lowerBound, double upperBound)
           
protected  void operate()
           
 void setFill(java.awt.Color _rgbValue)
           
 void setFill(double _grayValue)
           
 void setInputImage(MTBImage _inputImage)
           
 void setInvert()
           
 void setModification(ImageValueTools.ImageValueModification mod)
           
 void setNormFromTo(double minVal, double maxVal, double minVal_new, double maxVal_new)
           
 void setNormTo(double _lowerBound, double _upperBound)
           
 void validateCustom()
           
 
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, 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

fromMaxVal

@Parameter(label="fromMaxVal",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=8,
           description="Floating point reference maximum image value")
private double fromMaxVal

fromMinVal

@Parameter(label="fromMinVal",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=7,
           description="Floating point reference minimum image value")
private double fromMinVal

grayValue

@Parameter(label="grayValue",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=4,
           description="Floating point value to fill the image")
private java.lang.Double grayValue

inputImage

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

lowerBound

@Parameter(label="lowerBound",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=5,
           description="Floating point value for lower normalization bound")
private double lowerBound

modificationMode

@Parameter(label="modificationMode",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=2,
           description="Image value modification mode")
private ImageValueTools.ImageValueModification modificationMode

resultImage

@Parameter(label="resultImage",
           required=true,
           direction=OUT,
           mode=STANDARD,
           dataIOOrder=1,
           description="Result image")
private MTBImage resultImage

rgbValue

@Parameter(label="rgbValue",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=3,
           description="RGB color value to fill the image")
private java.awt.Color rgbValue

upperBound

@Parameter(label="upperBound",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=6,
           description="Floating point value for upper normalization bound")
private double upperBound
Constructor Detail

ImageValueTools

public ImageValueTools()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

ImageValueTools

protected ImageValueTools(MTBImage img)
                   throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor. Use set-functions to set the parameters.

Parameters:
img -
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

fill

protected void fill(MTBImage img,
                    java.awt.Color rgbvalue)

fill

protected void fill(MTBImage img,
                    double grayvalue)

fillImage

public static void fillImage(MTBImage img,
                             java.awt.Color rgbvalue,
                             MTBOperator callingOperator)
                      throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                             de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Fill the image with a RGB color value. If the input image is a gray value image, the RGB value is averaged for a gray value.

Parameters:
img -
rgbvalue -
callingOperator -
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

fillImage

public static void fillImage(MTBImage img,
                             double grayvalue,
                             MTBOperator callingOperator)
                      throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                             de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Fill the specified image with a gray value.

Parameters:
img -
grayvalue -
callingOperator -
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

getGrayValue

protected java.lang.Double getGrayValue()

getInputImage

public MTBImage getInputImage()

getLowerBound

protected double getLowerBound()
Get lower bound of the normalization to range [lowerBound, upperBound].

Returns:
Lower bound.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

getModification

protected ImageValueTools.ImageValueModification getModification()

getResultImage

public MTBImage getResultImage()

getRGBValue

protected java.awt.Color getRGBValue()

getUpperBound

protected double getUpperBound()
Get upper bound of the normalization to range [lowerBound, upperBound].

Returns:
Upper bound.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

invert

protected void invert(MTBImage img)

invertImage

public static void invertImage(MTBImage img,
                               MTBOperator callingOperator)
                        throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                               de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Invert the specified image. If the input image is not of type MTB_BYTE or MTB_RGB, the minimum and maximum image value are used to compute the inverted values to keep the values in the same range.

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

normFromTo

protected void normFromTo(MTBImage img)

normImageFromTo

public static void normImageFromTo(MTBImage img,
                                   double oldMinVal,
                                   double oldMaxVal,
                                   double newMinVal,
                                   double newMaxVal,
                                   MTBOperator callingOperator)
                            throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                   de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Normalize the image values to range [lowerBound, upperBound]. This method is useful mostly for gray value images.

Parameters:
img -
lowerBound -
upperBound -
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

normImageTo

public static void normImageTo(MTBImage img,
                               double lowerBound,
                               double upperBound,
                               MTBOperator callingOperator)
                        throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                               de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Normalize the image values to range [lowerBound, upperBound]. This method is useful mostly for gray value images.

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

normTo

protected void normTo(MTBImage img,
                      double lowerBound,
                      double upperBound)

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

setFill

public void setFill(java.awt.Color _rgbValue)
             throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

setFill

public void setFill(double _grayValue)
             throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

setInputImage

public void setInputImage(MTBImage _inputImage)

setInvert

public void setInvert()

setModification

public void setModification(ImageValueTools.ImageValueModification mod)

setNormFromTo

public void setNormFromTo(double minVal,
                          double maxVal,
                          double minVal_new,
                          double maxVal_new)

setNormTo

public void setNormTo(double _lowerBound,
                      double _upperBound)
               throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

validateCustom

public void validateCustom()
                    throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Overrides:
validateCustom in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException