de.unihalle.informatik.MiToBo.segmentation.thresholds
Class ImgThresh

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

@ALDAOperator(genericExecutionMode=ALL,
              level=STANDARD)
public class ImgThresh
extends MTBOperator

Image thresholding class.


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 actualSliceOnly
           
private  double bgValue
           
private  MTBImage destinationImage
           
private  double fgValue
           
private  MTBImage inputImage
           
private  MTBImage resultImage
           
private  MTBDoubleData threshold
           
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
ImgThresh()
           
ImgThresh(MTBImage img, double thres)
          Constructor for thresholding using 255 as foreground and 0 as background value.
ImgThresh(MTBImage img, double thres, double fg, double bg)
          Constructor for thresholding using 'fgValue' as foreground and 'bgValue' as background value.
 
Method Summary
 boolean getActualSliceOnly()
          Get flag for thresholding only the actual slice (true) or the whole image (false)
 double getBGValue()
          Get background value
 MTBImage getDestinationImage()
          Get value of Input argument DestinationImage.
 double getFGValue()
          Get foreground value
 MTBImage getInputImage()
          Get input image
 MTBImage getResultImage()
          Get the result image
 java.lang.Double getThreshold()
          Get threshold.
 boolean isBGOriginalValue()
          Test if background pixels keep their original pixel values
 boolean isFGOriginalValue()
          Test if foreground pixels keep their original pixel values
protected  void operate()
           
 void setActualSliceOnly()
          Only actual slice is thresholded, this will force the output image type to be of the same type as the input image (or destination image type)
 void setBGOriginalValue()
          Tell the thresholder to use the original pixel value for background pixels
 void setBGValue(double value)
          Set value of Parameter argument BGValue.
 void setDestinationImage(MTBImage img)
          Set value of Input argument DestinationImage.
 void setFGOriginalValue()
          Tell the thresholder to use the original pixel value for foreground pixels
 void setFGValue(double value)
          Set value of Parameter argument FGValue.
 void setInputImage(MTBImage img)
          Set input image
protected  void setResultImage(MTBImage img)
          Set result image.
 void setThreshold(double thres)
          Set threshold
protected  MTBImage threshold(MTBImage img, double thresh, double _fgValue, double _bgValue, boolean _actualSliceOnly)
          Apply threshold to an MTBImage and create a new thresholded MTBImage.
protected  void threshold(MTBImage img, MTBImage threshImg, double thresh, double fgValue, double bgValue, boolean actualSliceOnly)
          Apply threshold to an MTBImage and write results to a destination MTBImage.
 void unsetActualSliceOnly()
          The whole image is thresholded (default)
 
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

actualSliceOnly

@Parameter(label="Current slice only",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=5,
           description="Threshold only the current slice")
private boolean actualSliceOnly

bgValue

@Parameter(label="BG-value",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=4,
           description="Gray value for pixels >= threshold (background pixels). If value is INFINITY then the original pixel values are used.")
private double bgValue

destinationImage

@Parameter(label="Destination image",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=6,
           description="Optional destination image to draw to. If ommited a new image is created.")
private transient MTBImage destinationImage

fgValue

@Parameter(label="FG-value",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=3,
           description="Gray value for pixels >= threshold (foreground pixels). If value is INFINITY then the original pixel values are used.")
private double fgValue

inputImage

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

resultImage

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

threshold

@Parameter(label="Threshold",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=2,
           description="Threshold")
private MTBDoubleData threshold
Constructor Detail

ImgThresh

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

ImgThresh

public ImgThresh(MTBImage img,
                 double thres)
          throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor for thresholding using 255 as foreground and 0 as background value. The result image will be of type MTB_BYTE

Parameters:
img - input image
threshold - values < threshold are set to 0, value >= threshold are set to 255
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

ImgThresh

public ImgThresh(MTBImage img,
                 double thres,
                 double fg,
                 double bg)
          throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor for thresholding using 'fgValue' as foreground and 'bgValue' as background value. The result image will have the same type as the input image.

Parameters:
img - input image
thres - values < threshold are set to 'fgValue', value >= threshold are set to 'bgValue'
fg - foreground value (POSITIVE_INFINITY is interpreted as use original value)
bg - background value (POSITIVE_INFINITY is interpreted as use original value)
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

getActualSliceOnly

public boolean getActualSliceOnly()
Get flag for thresholding only the actual slice (true) or the whole image (false)


getBGValue

public double getBGValue()
Get background value

Returns:
background value

getDestinationImage

public MTBImage getDestinationImage()
Get value of Input argument DestinationImage.

Returns:
value of DestinationImage

getFGValue

public double getFGValue()
Get foreground value

Returns:
foreground value

getInputImage

public MTBImage getInputImage()
Get input image

Returns:
input image

getResultImage

public MTBImage getResultImage()
Get the result image

Returns:
result image

getThreshold

public java.lang.Double getThreshold()
Get threshold. Might be null if no threshold was specified, but this will cause an exception on runtime

Returns:
threshold

isBGOriginalValue

public boolean isBGOriginalValue()
Test if background pixels keep their original pixel values

Returns:
true if background pixels keep their original pixel values

isFGOriginalValue

public boolean isFGOriginalValue()
Test if foreground pixels keep their original pixel values

Returns:
true if foreground pixels keep their original pixel values

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

setActualSliceOnly

public void setActualSliceOnly()
Only actual slice is thresholded, this will force the output image type to be of the same type as the input image (or destination image type)


setBGOriginalValue

public void setBGOriginalValue()
Tell the thresholder to use the original pixel value for background pixels


setBGValue

public void setBGValue(double value)
Set value of Parameter argument BGValue.

Parameters:
value - New value for BGValue

setDestinationImage

public void setDestinationImage(MTBImage img)
Set value of Input argument DestinationImage.

Parameters:
img - destination image

setFGOriginalValue

public void setFGOriginalValue()
Tell the thresholder to use the original pixel value for foreground pixels


setFGValue

public void setFGValue(double value)
Set value of Parameter argument FGValue.

Parameters:
value - New value for FGValue

setInputImage

public void setInputImage(MTBImage img)
Set input image


setResultImage

protected void setResultImage(MTBImage img)
Set result image. You may specify a destination image to which the thresholding results are written. Otherwise the operator sets a new resulting image.

Parameters:
img - result image

setThreshold

public void setThreshold(double thres)
Set threshold


threshold

protected MTBImage threshold(MTBImage img,
                             double thresh,
                             double _fgValue,
                             double _bgValue,
                             boolean _actualSliceOnly)
Apply threshold to an MTBImage and create a new thresholded MTBImage. Specify values for foreground and background value. If fgValue/bgValue is Double.POSITIVE_INFINITY the original image values are used for foreground/background pixels. If fgValue == 255 and bgValue == 0 and !actualSliceOnly, the result image will be of type MTB_BYTE

Parameters:
img - source MTBImage
thresh - Threshold
fgValue - Foreground pixel value. If set to Double.POSITIVE_INFINITY, pixels higher than/equal to the threshold are set to their original values.
bgValue - Background pixel value. If set to Double.POSITIVE_INFINITY, pixels lower to the threshold are set to their original values.
actualSliceOnly - flag for only thresholding actual slice (true) or whole image (false)
Returns:
new thresholded MTBImage object

threshold

protected void threshold(MTBImage img,
                         MTBImage threshImg,
                         double thresh,
                         double fgValue,
                         double bgValue,
                         boolean actualSliceOnly)
                  throws java.lang.IllegalArgumentException
Apply threshold to an MTBImage and write results to a destination MTBImage. Specify values for foreground and background value. If fgValue/bgValue is Double.POSITIVE_INFINITY the original image values are used for foreground/background pixels.

Parameters:
img - source MTBImage
threshImg - destination image to write the thresholded result to
thresh - Threshold
fgValue - Foreground pixel value. If set to Double.POSITIVE_INFINITY, pixels higher than/equal to the threshold are set to their original values.
bgValue - Background pixel value. If set to Double.POSITIVE_INFINITY, pixels lower to the threshold are set to their original values.
actualSliceOnly - flag for only thresholding actual slice (true) or whole image (false)
Throws:
java.lang.IllegalArgumentException

unsetActualSliceOnly

public void unsetActualSliceOnly()
The whole image is thresholded (default)