You can use callbacks to change the structure of a workflow if certain conditions are met. In the following example, if the input raster for ISODATA classification has fewer than five bands, the workflow will skip the smoothing step. If the input raster has more than five bands, the workflow will execute the smoothing step.
Copy and paste this code into the IDL Editor. Save the file as rewire_workflow.pro. Then compile and run the program.
PRO rewire_workflow_postexecute, workflow, _REF_EXTRA=refExtra
COMPILE_OPT IDL2
step1 = workflow.GetStep('step_1')
step2 = workflow.GetStep('step_2')
step3 = workflow.GetStep('step_3')
IF (workflow.CURRENT_STEP.task.NUMBER_OF_CLASSES LE 5) THEN BEGIN
workflow.Disconnect, step1, step2
workflow.Disconnect, step2, step3
workflow.Connect, step1, 'OUTPUT_RASTER', step3, 'INPUT_RASTER'
ENDIF ELSE BEGIN
workflow.Disconnect, step1, step3
workflow.Connect, step1, 'OUTPUT_RASTER', step2, 'INPUT_RASTER'
workflow.Connect, step2, 'OUTPUT_RASTER', step3, 'INPUT_RASTER'
ENDELSE
END
PRO rewire_workflow
COMPILE_OPT IDL2
e = ENVI()
workflow = ENVIWorkflow()
workflow.TITLE = 'Classification Workflow'
workflow.DESCRIPTION = 'Goal: to segment an image into meaningful categories'
step1 = ENVIWorkflowStep()
step1.TASK = ENVITask('ISODATAClassification')
step1.TIMELINE_TITLE = 'Classification'
step1.NAME = 'step_1'
step1.CALLBACK_POSTEXECUTE = 'rewire_workflow_postexecute'
step2 = ENVIWorkflowStep()
step2.TASK = ENVITask('ClassificationSmoothing')
step2.TIMELINE_TITLE = 'Smoothing'
step2.NAME = 'step_2'
step3 = ENVIWorkflowStep()
step3.TASK = ENVITask('ClassificationToShapefile')
step3.TIMELINE_TITLE = 'Export'
step3.NAME = 'step_3'
workflow.Connect, step1, 'OUTPUT_RASTER', step2, 'INPUT_RASTER'
workflow.Connect, step2, 'OUTPUT_RASTER', step3, 'INPUT_RASTER'
envi.UI.CreateWorkflowDialog, workflow
END
See Also
Customize Workflows