ImageArithmetics¶
- class controllers.ImageArithmetics¶
Bases:
handleIMAGEARITHMETICS - Controller for image arithmetic operations in MIB3.
Drives custom arithmetic on one or several open datasets. Available from MIB -> Ribbon -> Image -> Tools for Images -> Image Arithmetics.
obj.startController('ImageArithmetics'); % GUI mode obj.startController('ImageArithmetics', [], BatchOpt); % headless batch obj.startController('ImageArithmetics', [], NaN); % query defaults- Constructor Summary
- ImageArithmetics(mibModel, varargin)¶
IMAGEARITHMETICS - Create and open the Image Arithmetics dialog.
- Syntax:
obj = ImageArithmetics(mibModel) obj = ImageArithmetics(mibModel, extraController) obj = ImageArithmetics(mibModel, [], BatchOpt) obj = ImageArithmetics(mibModel, [], NaN)
Supports three operational modes:
GUI mode -
(mibModel)or(mibModel, extra): creates and shows the AppDesigner dialog.Batch mode -
(mibModel, [], BatchOpt): evaluates the expression inBatchOpt.Expressionheadlessly and returns.Query mode -
(mibModel, [], NaN): firesSyncBatchwith the defaultBatchOptso the Batch controller can read available options.
- Input Arguments:
mibModel - handle to the MibModel instance
varargin - (optional) extra arguments:
varargin{1}- extra controller handle (unused, pass[])varargin{2}- BatchOpt struct for batch mode, orNaNfor query mode
- Output Arguments:
obj - handle to the new ImageArithmetics instance
- Property Summary
- BatchOpt¶
cell array with handles to listeners
- listener¶
handle to the view (core.ChildView)
- mibModel¶
- view¶
handle to the model
- Method Summary
- Expression_ValueChangedFcn(hObject)¶
EXPRESSION_VALUECHANGEDFCN - Sync the Expression textarea value to BatchOpt.
- Syntax:
obj.Expression_ValueChangedFcn(hObject)
uitextarea.Valueis a cell array of lines; joins them with newlines before storing inobj.BatchOpt.Expression.- Input Arguments:
hObject - handle to the
Expressionuitextarea widget
- Output Arguments:
(none)
- static ViewListner_Callback2(~, evnt)¶
VIEWLISTNER_CALLBACK2 - Guard callback: clean up stale listeners if the view was closed.
- Syntax:
ImageArithmetics.ViewListner_Callback2(obj, src, evnt)
If the view window is no longer valid (closed before the listener was removed), deletes all listeners and returns silently. Otherwise dispatches to
updateWidgetsfor the relevant events.- Input Arguments:
obj - handle to the ImageArithmetics controller instance
src - event source (handle to MibModel); ignored
evnt - event data;
evnt.EventNameidentifies the event
- Output Arguments:
(none)
- addCallbacks()¶
ADDCALLBACKS - Wire all widget callbacks; called once from the constructor.
- Syntax:
obj.addCallbacks()
Sets
CloseRequestFcnon the figure first, then assignsValueChangedFcn/ButtonPushedFcnto every interactive widget.- Output Arguments:
(none)
- closeWindow()¶
CLOSEWINDOW - Delete the dialog window and release all listeners.
- Syntax:
obj.closeWindow()- Output Arguments:
(none)
- helpBtn_Callback()¶
HELPBTN_CALLBACK - Open the Image Arithmetics help page in a browser.
- Syntax:
obj.helpBtn_Callback()- Output Arguments:
(none)
- prevExpPopup_Callback()¶
PREVEXPPOPUP_CALLBACK - Restore a previously used expression from the history dropdown.
- Syntax:
obj.prevExpPopup_Callback()
The dropdown displays newline-stripped versions of stored expressions. On selection the matching full expression (with embedded newlines) is retrieved from
preferences.ImageArithmetic.Actionsand written back to the Expression textarea and the BatchOpt fields.- Output Arguments:
(none)
- returnBatchOpt(BatchOptOut)¶
RETURNBATCHOPT - Return the BatchOpt structure to the Batch controller via the SyncBatch event.
- Syntax:
obj.returnBatchOpt() obj.returnBatchOpt(BatchOptOut)- Input Arguments:
BatchOptOut - (optional) local BatchOpt structure generated during the run callback; may contain more fields than
obj.BatchOpt. When omitted,obj.BatchOptis used.
- Output Arguments:
(none)
- runExpressionBtn_Callback()¶
RUNEXPRESSIONBTN_CALLBACK - Evaluate the arithmetic expression and write the result.
- Syntax:
obj.runExpressionBtn_Callback()
Operates in both GUI and headless batch mode. Steps:
Parse
BatchOpt.InputVariablesand fetch each dataset viamibModel.getData4Dinto workspace variables (I,O,M,S,I2, etc.).Evaluate
BatchOpt.Expressionwithevaland pick up the resulting variable named inBatchOpt.OutputVariables.Write the result back via
mibModel.setData4D. When the target container differs from the source, a newcore.MibDatasetis created andNewDatasetis fired.Store the expression in
preferences.ImageArithmetichistory and fireSyncBatch.
- Output Arguments:
(none)
Set up progress bar (works in both GUI and headless mode)
- updateBatchOptFromGUI(hObject)¶
UPDATEBATCHOPTFROMGUI - Update
obj.BatchOptfrom a GUI widget value-change event.- Syntax:
obj.updateBatchOptFromGUI(hObject)
Delegates to
utils.updateBatchOptFromGUI_Shared, which is common to all batch-compatible tools.- Input Arguments:
hObject - handle to the widget that changed; in AppDesigner callbacks this is the event source (
event.Source)
- Output Arguments:
(none)
- updateWidgets(~)¶
UPDATEWIDGETS - Refresh dialog widgets from the current model state.
- Syntax:
obj.updateWidgets()
This dialog has no model-driven widgets beyond what the constructor populates, so the method is intentionally empty.
- Output Arguments:
(none)