GlobalThresholding¶
- class controllers.GlobalThresholding¶
Bases:
handleGLOBALTHRESHOLDING - Controller for automatic black-and-white thresholding.
Applies one of 12 histogram-based thresholding algorithms (Otsu, Entropy, Concavity, Percentile, …) to the selected color channel of the image layer and writes the binary result to the selection or mask layer.
Launch as GUI tool:
obj.mibController.startController('controllers.GlobalThresholding');Launch in batch mode:
BatchOpt.Algorithm = {'Otsu'}; BatchOpt.Mode = {'3D, Stack'}; BatchOpt.Destination = {'mask'}; obj.mibController.startController('controllers.GlobalThresholding', [], BatchOpt);Trigger return of default options:
obj.mibController.startController('controllers.GlobalThresholding', [], NaN);- Constructor Summary
- GlobalThresholding(mibModel, varargin)¶
GLOBALTHRESHOLDING - Constructor.
- Syntax:
obj = GlobalThresholding(mibModel) obj = GlobalThresholding(mibModel, [], BatchOpt) obj = GlobalThresholding(mibModel, [], NaN)
- Property Summary
- BatchOpt¶
cell array of listener handles
- listener¶
handle to main MIB figure (used as parent for dialogs)
- mibGUI¶
handle to the view (views.GlobalThresholdingGUI)
- mibModel¶
- view¶
handle to MibModel
- Method Summary
- static ViewListner_Callback2(~, evnt)¶
VIEWLISTNER_CALLBACK2 - Static listener guard; safe even after close.
- addCallbacks()¶
ADDCALLBACKS - Wire all widget callbacks after view creation.
- algorithmChanged(event)¶
ALGORITHMCHANGED - Handle Algorithm dropdown change.
- applyButton_Callback(batchModeSwitch)¶
APPLYBUTTON_CALLBACK - Perform thresholding on the selected scope.
- Input Arguments:
batchModeSwitch (optional) - logical;
truewhen called headlessly from the batch dispatcher. Defaultfalse.
- applyUIRules()¶
APPLYUIRULES - Enable/disable Percentile controls and update info text.
- autoPreviewChanged(event)¶
AUTOPREVIEWCHANGED - Handle autoPreview checkbox; fire preview if just checked.
- closeWindow()¶
CLOSEWINDOW - Destroy view, listeners, fire CloseEvent.
- computeThreshold(img, algorithm, foregroundFraction, maxInt)¶
COMPUTETHRESHOLD - Apply the selected thresholding algorithm to img.
- Input Arguments:
img - [uint8 | uint16] single-channel 2-D image
algorithm - [char] algorithm name from BatchOpt.Algorithm{1}
foregroundFraction - [double] fraction for Percentile algorithm
maxInt - [double] maximum intensity for the image data type
- Output Arguments:
threshold - [double] raw intensity threshold value
- figureKeyPress(event)¶
FIGUREKEYPRESS - Forward key presses to MIB main window shortcuts.
- foregroundFractionChanged(event)¶
FOREGROUNDFRACTIONCHANGED - Handle ForegroundFraction spinner change; sync slider.
- foregroundSliderChanged(event)¶
FOREGROUNDSLIDERCHANGED - Handle foregroundSlider change; sync spinner.
- getInfoText()¶
GETINFOTEXT - Return description for the currently selected algorithm.
- helpButton_Callback()¶
HELPBUTTON_CALLBACK - Open documentation in browser.
- offsetSliderChanged(event)¶
OFFSETSLIDERCHANGED - Handle offsetSlider change; sync spinner.
- previewBtn_Callback()¶
PREVIEWBTN_CALLBACK - Apply thresholding to the current slice and show in selection.
- resetSliders_Callback()¶
RESETSLIDERS_CALLBACK - Reset ForegroundFraction to 0.5 and ThresholdOffset to 0.
- returnBatchOpt(BatchOptOut)¶
RETURNBATCHOPT - Send BatchOpt to mibBatchController.
- thresholdOffsetChanged(event)¶
THRESHOLDOFFSETCHANGED - Handle ThresholdOffset spinner change; sync slider.
- triggerAutoPreview()¶
TRIGGERAUTPREVIEW - Fire preview when autoPreview checkbox is on.
- updateBatchOptFromGUI(event)¶
UPDATEBATCHOPTFROMGUI - Sync BatchOpt from a widget change event.
- updateWidgets()¶
UPDATEWIDGETS - Refresh widgets to reflect current model state.