This example shows how perform classification smoothing (using the ClassificationSmoothing task) and automatically apply it to the classification result without requiring a separate step. Use the CALLBACK_POST_EXECUTE property to invoke the smoothing task after the ISODATA classification task.

Copy and paste this code into the IDL Editor. Save the file as example_postexecute.pro. Then compile and run the program.

; This is the routine to invoke using the POSTEXECUTE callback.
; It accepts the workflow as an argument.
 
PRO example_postexecute_postexecute, workflow, _REF_EXTRA=refExtra
COMPILE_OPT IDL2
 
; Get the smoothing task from the catalog of ENVITasks
task = ENVITask('ClassificationSmoothing')
 
; The input for this task is the output raster from
; the ISODATA classification task, which is the
; "current" task when the callback is invoked
task.INPUT_RASTER = workflow.CURRENT_STEP.task.OUTPUT_RASTER
 
; Define the smoothing kernel size
task.KERNEL_SIZE = 25
 
; Run the smoothing task
task.Execute
 
; Substitute the step output for this raster
workflow.CURRENT_STEP.task.OUTPUT_RASTER = task.OUTPUT_RASTER
 
; For debugging purposes, load both rasters 
; in order to see the difference
view = envi.GetView()
!null = view.CreateLayer(task.INPUT_RASTER)
!null = view.CreateLayer(task.OUTPUT_RASTER)
END
 
; -----------------------------------------------
 
; This is the workflow routine
 
PRO example_postexecute
COMPILE_OPT IDL2
 
; Start the application
e = ENVI()
 
; Create and customize a workflow
workflow = ENVIWorkflow()
workflow.TITLE = 'Classification Workflow'
workflow.DESCRIPTION = 'In this example, smoothing happens invisibly between steps.'
 
; Add a step for ISODATA classification
step1 = ENVIWorkflowStep()
step1.TASK = ENVITask('ISODATAClassification')
step1.TIMELINE_TITLE = 'Classification'
 
; After the task runs, call the 
; example_postexecute_postexecute routine
step1.CALLBACK_POSTEXECUTE = 'example_postexecute_postexecute'
 
; Add a step to convert the classification image
; to a vector shapefile
step2 = ENVIWorkflowStep()
step2.TASK = ENVITask('ClassificationToShapefile')
step2.TIMELINE_TITLE = 'Vectorize'
 
; Connect the output from Step 1 to the input for Step 2
workflow.Connect, step1, 'OUTPUT_RASTER', step2, 'INPUT_RASTER'
 
; Run and display the workflow
envi.UI.CreateWorkflowDialog, workflow
END

 

Result:

See Also


Customize Workflows