@ALDAOperator(genericExecutionMode=ALL, shortDescription="Image binarization based on local Niblack thresholding.") public class ImgThreshNiblack extends MTBOperator
The implementation is based upon the following publications:
Note that the enhanced Niblack mode as proposed by Zhang et al. is quite similar to the Sauvola local thresholding approach published in
This class implements various versions of the Niblack thresholding approach. It calculates local thresholds according to the given input parameters and applies them to the given image. As result a binary image is returned.
Provided methods include conventional and enhanced Niblack
thresholding, either applied in a sliding window manner or maskwise.
In the latter case the windows are not overlapping. The maskwise
application has particularly profen suitable for granule
detection.
The operator allows for activation of an additional local variance
check. If activated, only windows are thresholded where the
variance exceeds a certain threshold. All other windows are assumed
to contain more or less homogeneous intensities and are classified as
background.
In standard mode, as proposed by Niblack, the operator calculates a local threshold T based on the local mean m and standard deviation s in a local sliding window around pixel (x,y):
In additon to the standard version of the Niblack approach the operator also implements an enhanced version as proposed by Zhang et al:
Modifier and Type | Class and Description |
---|---|
static class |
ImgThreshNiblack.Mode
Niblack processing mode.
|
Modifier and Type | Field and Description |
---|---|
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.
|
Constructor and Description |
---|
ImgThreshNiblack()
Default constructor.
|
ImgThreshNiblack(MTBImage _inImg,
ImgThreshNiblack.Mode mode,
double k,
double R,
int wSize,
int vcNB,
double vcThresh,
MTBImageByte _mask)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
getDocumentation() |
MTBImageByte |
getResultImage()
Get the resulting thresholded image.
|
protected void |
operate() |
void |
setInputImage(MTBImage img)
Set input image.
|
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getHidingMode, getInactiveParameterNames, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterDescriptorUnconditioned, getParameterNames, getParameterUnconditioned, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, hasInOutParameters, hasParameter, isAnnotatedParameter, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, removeParameter, runOp, runOp, runOp, setConstructionMode, setConstructionMode, setConstructionMode, setHidingMode, setName, setParameter, setParameterUnconditioned, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="Input image", required=true, direction=IN, description="Input image.") private transient MTBImage inImg
@Parameter(label="Result image", required=true, direction=OUT, description="Output image.") private transient MTBImageByte outImg
@Parameter(label="Mode", required=true, direction=IN, description="Process Mode.") private ImgThreshNiblack.Mode processMode
@Parameter(label="K", direction=IN, description="Scaling factor K.", dataIOOrder=-8) private double scalingK
@Parameter(label="R", direction=IN, description="Enhancement factor R, disabled if -1.", dataIOOrder=-7) private double enhanceR
@Parameter(label="Window size", direction=IN, description="Local window size.", dataIOOrder=-15) private int winSize
@Parameter(label="Variance threshold", direction=IN, description="Variance check threshold", dataIOOrder=-4) private double varCheckThresh
Image areas with a variance below the threshold are classified as background because the Niblack criterion will most likely fail.
varCheckNB
@Parameter(label="Variance check neighborhood", direction=IN, dataIOOrder=-5, description="Variance check neighborhood size.") private int varCheckNB
varCheckThresh
@Parameter(label="Exclude Mask", direction=IN, required=false, description="Exclude mask", dataIOOrder=-10) private MTBImageByte mask
public ImgThreshNiblack() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.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
_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.vcNB
- Size of neighborhood for local variance check.vcThresh
- Threshold for local variance check._mask
- Image mask for excluding image sections.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.public MTBImageByte getResultImage()
public void setInputImage(MTBImage img)
img
- Image to process.protected void operate()
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
private MTBImageByte applyNiblackThreshold(MTBImage mimg, int w, double k, double R)
mimg
- Input image to process.w
- Size of sliding window.k
- Niblack factor.R
- Niblack normalization constant.private MTBImageByte applyNiblackThresholdMaskwise(MTBImage mimg, int w, double k, double R)
private MTBImageByte applyNiblackThreshold_withLocalVarCheck(MTBImage mimg, int w, double k, double R, int varCheckNeighborhood, double localVarThresh)
@Deprecated public ij.ImagePlus applyNiblackThresholdWholeImage(ij.process.ImageProcessor ip, double k, double R, ij.ImagePlus _mask)
private MTBImageByte applyNiblackThresholdWholeImage(MTBImage mimg, double k, double R)
ip
- input image processork
- Niblack factorR
- Niblack normalization constantpublic String getDocumentation()
getDocumentation
in class de.unihalle.informatik.Alida.operator.ALDOperator
Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.