A copy of this file is also available in the \examples\tasks\baseclassexample folder of the ENVI installation path.

PRO RunImageThresholdExampleTask
  compile_opt idl2, hidden
   
  ; Start the application
  e = ENVI(LAYOUT=[2,2])
  views = e.GetView(/ALL)
   
  ; Open an input file
  File = Filepath('qb_boulder_msi', Subdir=['data'], $
    Root_Dir=e.Root_Dir)
  Raster = e.OpenRaster(File)
   
  ; Generate a max entropy threshold from input
  maxEntropyTask = ENVITask('MaxEntropyThresholdExample')
  maxEntropyTask.INPUT_RASTER = Raster
  maxEntropyTask.Execute
   
  ; Generate an min error threshold from input
  minErrorTask = ENVITask('MinErrorThresholdExample')
  minErrorTask.INPUT_RASTER = Raster
  minErrorTask.Execute
   
  ; Generate an mean threshold from input
  meanTask = ENVITask('MeanThresholdExample')
  meanTask.INPUT_RASTER = Raster
   
  ; Set the minimum to the max minimum of all bands and set the maximum
  ; to the min maximum of all bands
  stats = ENVIRasterStatistics(Raster)
  meanTask.Minimum = MIN(stats.Mean)
  meanTask.Maximum = MAX(stats.Mean)
  meanTask.Execute
   
  ; Display the original and outputs
  origLayer = (views[0]).CreateLayer(Raster, BAND=0)
  maxEntropyLayer = (views[1]).CreateLayer(maxEntropyTask.OUTPUT_RASTER, BAND=0)
  minErrorLayer = (views[2]).CreateLayer(minErrorTask.OUTPUT_RASTER, BAND=0)
  meanLayer = (views[3]).CreateLayer(meanTask.OUTPUT_RASTER, BAND=0)
END