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

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

@ALDAOperator(genericExecutionMode=ALL)
public class ImgThreshNiblack
extends MTBOperator

Niblack binarization.

Class that offers methods for applying Niblack thresholding to an image, using parameters as specified. Provided methods include conventional Niblack thresholding, application maskwise and, particularly suitable for granule detection, thresholding with additional local variance checks.

Author:
moeller

Nested Class Summary
static class ImgThreshNiblack.Mode
          Niblack processing mode.
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
private  double enhanceR
          Niblack factor R.
private  MTBImage inImg
          Input image.
private  MTBImageByte mask
          Optional mask for excluding image regions from processing.
private  MTBImageByte outImg
          Binary result image.
private  ImgThreshNiblack.Mode processMode
          Process mode.
private  double scalingK
          Niblack scaling parameter k.
private  int varCheckNB
          Size of neighborhood for local variance checks.
private  double varCheckThresh
          Threshold for variance check.
private  int winSize
          Size of local sliding window.
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
ImgThreshNiblack()
          Default constructor.
ImgThreshNiblack(MTBImage _inImg, ImgThreshNiblack.Mode mode, double k, double R, int wSize, int vcNB, double vcThresh, MTBImageByte _mask)
          Default destructor.
 
Method Summary
private  MTBImageByte applyNiblackThreshold_withLocalVarCheck(MTBImage mimg, int w, double k, double R, int varCheckNeighborhood, double localVarThresh)
          This function implements the conventional Niblack binarization, enhanced with a local variance check.
private  MTBImageByte applyNiblackThreshold(MTBImage mimg, int w, double k, double R)
          This function implements the conventional (enhanced) Niblack binarization.
private  MTBImageByte applyNiblackThresholdMaskwise(MTBImage mimg, int w, double k, double R)
          Enhanced Niblack binarization applied maskwise to the image, i.e. all pixels inside the mask get the same threshold.
 ij.ImagePlus applyNiblackThresholdWholeImage(ij.process.ImageProcessor ip, double k, double R, ij.ImagePlus _mask)
          Deprecated. 
private  MTBImageByte applyNiblackThresholdWholeImage(MTBImage mimg, double k, double R)
          This function implements the conventional (enhanced) Niblack binarization.
 MTBImageByte getResultImage()
          Get the resulting thresholded image.
protected  void operate()
           
 void setInputImage(MTBImage img)
          Set input image.
 
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

enhanceR

@Parameter(label="R",
           direction=IN,
           description="Enhancement factor R, disabled if -1.",
           dataIOOrder=-7)
private double enhanceR
Niblack factor R.


inImg

@Parameter(label="Input image",
           required=true,
           direction=IN,
           description="Input image.")
private transient MTBImage inImg
Input image.


mask

@Parameter(label="Exclude Mask",
           direction=IN,
           required=false,
           description="Exclude mask",
           dataIOOrder=-10)
private MTBImageByte mask
Optional mask for excluding image regions from processing.


outImg

@Parameter(label="Result image",
           required=true,
           direction=OUT,
           description="Output image.")
private transient MTBImageByte outImg
Binary result image.


processMode

@Parameter(label="Mode",
           required=true,
           direction=IN,
           description="Process Mode.")
private ImgThreshNiblack.Mode processMode
Process mode.


scalingK

@Parameter(label="K",
           direction=IN,
           description="Scaling factor K.",
           dataIOOrder=-8)
private double scalingK
Niblack scaling parameter k.


varCheckNB

@Parameter(label="Variance check neighborhood",
           direction=IN,
           description="Variance check neighborhood size.",
           dataIOOrder=-5)
private int varCheckNB
Size of neighborhood for local variance checks.

See Also:
varCheckThresh

varCheckThresh

@Parameter(label="Variance threshold",
           direction=IN,
           description="Variance check threshold",
           dataIOOrder=-4)
private double varCheckThresh
Threshold for variance check.

Image areas with a variance below the threshold are classified as background because the Niblack criterion will most likely fail.

See Also:
varCheckNB

winSize

@Parameter(label="Window size",
           direction=IN,
           description="Local window size.",
           dataIOOrder=-15)
private int winSize
Size of local sliding window.

Constructor Detail

ImgThreshNiblack

public ImgThreshNiblack()
                 throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Default constructor.

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

ImgThreshNiblack

public ImgThreshNiblack(MTBImage _inImg,
                        ImgThreshNiblack.Mode mode,
                        double k,
                        double R,
                        int wSize,
                        int vcNB,
                        double vcThresh,
                        MTBImageByte _mask)
                 throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Default destructor. A new empty meta data object is initialized.

Parameters:
_inImg - Image to work on.
mode - Mode for Niblack operator.
k - Scaling factor for standard deviation.
R - If unequal to -1, enhanced Niblack is applied.
wSize - Size of sliding window for local thresholding.
varCheckNB - Size of neighborhood for local variance check.
varCheckThresh - Threshold for local variance check.
_mask - Image mask for excluding image sections.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

applyNiblackThreshold_withLocalVarCheck

private MTBImageByte applyNiblackThreshold_withLocalVarCheck(MTBImage mimg,
                                                             int w,
                                                             double k,
                                                             double R,
                                                             int varCheckNeighborhood,
                                                             double localVarThresh)

applyNiblackThreshold

private MTBImageByte applyNiblackThreshold(MTBImage mimg,
                                           int w,
                                           double k,
                                           double R)
This function implements the conventional (enhanced) Niblack binarization. If R equals -1, the non-enhanced conventional variant is used.

Parameters:
ip - input image processor
w - size of sliding window
k - Niblack factor
R - Niblack normalization constant
Returns:
Niblack thresholded image.
LaTeX:

%preamble{\usepackage{amssymb}} Niblack binarization:


applyNiblackThresholdMaskwise

private MTBImageByte applyNiblackThresholdMaskwise(MTBImage mimg,
                                                   int w,
                                                   double k,
                                                   double R)

applyNiblackThresholdWholeImage

@Deprecated
public ij.ImagePlus applyNiblackThresholdWholeImage(ij.process.ImageProcessor ip,
                                                               double k,
                                                               double R,
                                                               ij.ImagePlus _mask)
Deprecated. 


applyNiblackThresholdWholeImage

private MTBImageByte applyNiblackThresholdWholeImage(MTBImage mimg,
                                                     double k,
                                                     double R)
This function implements the conventional (enhanced) Niblack binarization. If R equals -1, the non-enhanced conventional variant is used. Here no sliding window is required since the whole image area is taken as input image region. Consequently this method does a global binarization applying a single threshold on each image pixel.

Parameters:
ip - input image processor
k - Niblack factor
R - Niblack normalization constant
Returns:
Niblack thresholded image.
LaTeX:

%preamble{\usepackage{amssymb}} Niblack binarization:


getResultImage

public MTBImageByte getResultImage()
Get the resulting thresholded image.

Returns:
Binary image.

operate

protected void operate()
Specified by:
operate in class de.unihalle.informatik.Alida.operator.ALDOperator

setInputImage

public void setInputImage(MTBImage img)
Set input image.

Parameters:
img - Image to process.