@ALDAOperator(genericExecutionMode=ALL, shortDescription="Otsu\'s method for calculating global thresholds for image binarization.") public class CalcGlobalThreshOtsu extends MTBOperator
Basically, the optimal threshold is defined as the threshold which best separates the image histogram in two classes, more or less equal in size and well-separated in terms of their average intensities.
The threshold calculation is based on the following goal function,
Since the number of possible thresholds is directly linked to the number of histogram bins and, hence, to the computation time the maximum number of possible bins is restricted to 1024 in this implementation to keep the computational effort acceptable.
Reference: Nobuyuki Otsu, "A threshold selection method from gray-level histograms", IEEE Trans. Sys., Man., Cyber. 9 (1): 62–66, 1979.
Modifier and Type | Class and Description |
---|---|
static class |
CalcGlobalThreshOtsu.InputType
Type of input to work on.
|
Modifier and Type | Field and Description |
---|---|
private MTBImageHistogram |
inHisto
Input histogram.
|
private MTBImage |
inImg
Input image.
|
private CalcGlobalThreshOtsu.InputType |
inType
Input type.
|
private MTBDoubleData |
threshold
Result threshold.
|
Constructor and Description |
---|
CalcGlobalThreshOtsu()
Default constructor.
|
CalcGlobalThreshOtsu(MTBImage img)
Default constructor with input image as argument.
|
CalcGlobalThreshOtsu(MTBImageHistogram histo)
Default constructor with input histogram as argument.
|
Modifier and Type | Method and Description |
---|---|
private MTBDoubleData |
calcThreshold(MTBImage image)
Calculate Otsu threshold on given image.
|
private MTBDoubleData |
calcThreshold(MTBImageHistogram histo)
Calculate Otsu threshold on given histogram.
|
String |
getDocumentation() |
MTBDoubleData |
getOtsuThreshold()
Get the resulting threshold.
|
private void |
inputTypeChanged()
Callback routine to change parameters on change of input type.
|
protected void |
operate() |
void |
validateCustom() |
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, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="Input Type", required=true, dataIOOrder=0, supplemental=false, callback="inputTypeChanged", direction=IN, description="Type of input data.", paramModificationMode=MODIFIES_INTERFACE) private CalcGlobalThreshOtsu.InputType inType
@Parameter(label="Input Image", required=true, supplemental=false, dataIOOrder=1, direction=IN, description="Input image.") private transient MTBImage inImg
@Parameter(label="Input Histogram", required=true, supplemental=false, dataIOOrder=1, direction=IN, description="Input histogram") private transient MTBImageHistogram inHisto
@Parameter(label="Threshold", supplemental=false, direction=OUT, description="Result threshold") private MTBDoubleData threshold
public CalcGlobalThreshOtsu() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown if construction fails.public CalcGlobalThreshOtsu(MTBImage img) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
img
- Input image.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown if construction fails.public CalcGlobalThreshOtsu(MTBImageHistogram histo) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
histo
- Input histogram.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown if construction fails.public void validateCustom() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
validateCustom
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public MTBDoubleData getOtsuThreshold()
protected void operate()
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
private MTBDoubleData calcThreshold(MTBImage image)
image
- MiToBo image.private MTBDoubleData calcThreshold(MTBImageHistogram histo)
histo
- Histogram.private void inputTypeChanged()
public 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.