This task generates a classification image from a raster by applying either one or two threshold values to segment the data into distinct classes.
This task generates a classification image from a raster by applying either one or two threshold values to segment the data into distinct classes.
Example
This example performs a difference analysis between two images from different dates, then it sets thresholding values for change detection. The images represent NCEP-Reanalysis 2 air temperatures (K) at the 1000-isobar level, at 0600 hours Zulu time. The first image is from 29 December 2012, and the second is from 31 December 2012. Each image has one band. This example uses sample data from the ENVI installation path.
e = ENVI()
TimeSeriesDir = Filepath('', Subdir=['data','time_series'], $
Root_Dir = e.Root_Dir)
files = File_Search(TimeSeriesDir, 'AirTemp*.dat')
numRasters = N_Elements(files)
rasters = ObjArr(numRasters)
FOR i=0, (numRasters-1) DO $
rasters[i] = e.OpenRaster(files[i])
Task = ENVITask('BuildTimeSeries')
Task.INPUT_RASTERS = rasters
Task.Execute
SeriesFile = Task.OUTPUT_RASTERSERIES
SeriesFile.Set, 0
Image1 = SeriesFile.Raster
SeriesFile.Set, 8
Image2 = SeriesFile.Raster
Task = ENVITask('ImageBandDifference')
Task.INPUT_RASTER1 = Image1
Task.INPUT_RASTER2 = Image2
Task.OUTPUT_RASTER_URI = e.GetTemporaryFilename()
Task.Execute
ChangeThresholdTask = ENVITask('ChangeThresholdClassification')
ChangeThresholdTask.INPUT_RASTER = Task.OUTPUT_RASTER
ChangeThresholdTask.INCREASE_THRESHOLD = 0.8
ChangeThresholdTask.DECREASE_THRESHOLD = 0.3
ChangeThresholdTask.Execute
DataColl = e.Data
DataColl.Add, ChangeThresholdTask.OUTPUT_RASTER
View = e.GetView()
Layer = View.CreateLayer(ChangeThresholdTask.OUTPUT_RASTER)
Syntax
Result = ENVITask('ChangeThresholdClassification')
Input parameters (Set, Get): DECREASE_THRESHOLD, INCREASE_THRESHOLD, INPUT_RASTER, OUTPUT_RASTER_URI
Output parameters (Get only): OUTPUT_RASTER
Parameters marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Parameters marked as "Get" are those whose values you can retrieve but not set.
Input Parameters
DECREASE_THRESHOLD (optional)
Pixels with value higher than this threshold will be classified as 'increase'.
INCREASE_THRESHOLD (optional)
Pixels with value lower than this threshold will be classified as 'decrease'.
INPUT_RASTER (required)
Specify a raster on which to threshold.
OUTPUT_RASTER_URI (optional)
Specify a string with the fully qualified filename and path of the associated OUTPUT_RASTER.
- If you do not specify this parameter, or set it to an exclamation symbol (!), ENVI creates a temporary file.
- If you set it to the hash symbol (#), ENVI creates a file in the temporary directory, but this file will not be deleted when ENVI closes.
Output Parameters
OUTPUT_RASTER
This is a reference to the output raster of filetype ENVI.
Methods
Execute
Parameter
ParameterNames
Properties
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
TAGS
Version History
See Also
AutoChangeThresholdClassification Task, Masking Support in ENVITasks