de.unihalle.informatik.MiToBo.enhance
Class GammaCorrection2D

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

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

Gamma correction on a 8- oder 16-bit image for one- or multi-channel images. The gamma value can be set or automatically be computed.

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  boolean auto
           
private  int channel
           
private  double gamma
           
private  MTBImage inputImage
           
private  MTBImage resultImage
           
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
GammaCorrection2D()
          Standard constructor.
GammaCorrection2D(MTBImage inimg, double _gamma, int _channel)
          Constructor to create a new gamma correction 2D operator.
GammaCorrection2D(MTBImage inimg, int _channel)
          No gamma value is set.
 
Method Summary
private  MTBImage correctGamma(MTBImage inputImg, double gamma, int channel)
          Perform gamma correction to the specified channel of the input image, using the given gamma value.
private  MTBImage correctGammaAuto(MTBImage inputImg, int channel)
          Perform gamma correction to the specified channel of the input image.
 int getChannel()
          Get the image channel.
 double getGamma()
          Get the gamma value.
 boolean getGammaToAuto()
          Get if gamma should be calculated automatically or not.
 MTBImage getInputImage()
          Get the input image.
 MTBImage getResultImage()
          Get the gamma corrected image.
protected  void operate()
          This method does the actual work.
 void setChannel(int _channel)
          Set the image channel.
 void setGamma(double _gamma)
          Set the gamma value.
 void setGammaToAuto(boolean a)
          Set if gamma should be calculated automatically or not.
 void setInputImage(MTBImage inImg)
          Set the input image.
 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

auto

@Parameter(label="Auto Gamma",
           required=false,
           direction=IN,
           description="Automatic gamma value computation.",
           mode=STANDARD,
           dataIOOrder=3)
private boolean auto

channel

@Parameter(label="Image Channel",
           required=true,
           direction=IN,
           description="Channel of image.",
           mode=STANDARD,
           dataIOOrder=2)
private int channel

gamma

@Parameter(label="Gamma Value",
           direction=INOUT,
           description="Gamma value.",
           mode=STANDARD,
           dataIOOrder=1)
private double gamma

inputImage

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

resultImage

@Parameter(label="Result Image",
           direction=OUT,
           description="Gamma corrected image.")
private transient MTBImage resultImage
Constructor Detail

GammaCorrection2D

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

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

GammaCorrection2D

public GammaCorrection2D(MTBImage inimg,
                         double _gamma,
                         int _channel)
                  throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor to create a new gamma correction 2D operator.

Parameters:
inimg - 2D input image for gamma correction
_gamma - gamma value to apply gamma correction
_channel - image channel to apply gamma correction
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

GammaCorrection2D

public GammaCorrection2D(MTBImage inimg,
                         int _channel)
                  throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
No gamma value is set. The gamma value is computed automatically.

gamma = log(r/maxInt)/ log(mean/maxInt)

maxInt is the maximum pixel intensity for all pixels in the image, for example 65535 for a 16-Bit pixel image

mean is the mean value over all image pixels

r is the half value of the pixel intensity range (32768 for 16-bit image)

Parameters:
inimg - 2D input image for gamma correction
_channel - image channel to apply gamma correction
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

correctGamma

private MTBImage correctGamma(MTBImage inputImg,
                              double gamma,
                              int channel)
Perform gamma correction to the specified channel of the input image, using the given gamma value.

Returns:
Gamma corrected image.

correctGammaAuto

private MTBImage correctGammaAuto(MTBImage inputImg,
                                  int channel)
Perform gamma correction to the specified channel of the input image. The gamma value is calculated automatically.

Returns:
Gamma corrected image.

getChannel

public int getChannel()
Get the image channel.


getGamma

public double getGamma()
Get the gamma value.


getGammaToAuto

public boolean getGammaToAuto()
Get if gamma should be calculated automatically or not.


getInputImage

public MTBImage getInputImage()
Get the input image.


getResultImage

public MTBImage getResultImage()
Get the gamma corrected image.


operate

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

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

setChannel

public void setChannel(int _channel)
Set the image channel.


setGamma

public void setGamma(double _gamma)
Set the gamma value.


setGammaToAuto

public void setGammaToAuto(boolean a)
Set if gamma should be calculated automatically or not.


setInputImage

public void setInputImage(MTBImage inImg)
Set the input image.


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