ClassActivationToPixelROI Task

This task creates pixel regions of interest (ROIs) from a class activation raster generated by a deep learning model.

The ROIs created with this tool can be combined with the original ROIs to create new label rasters to either train a new model again or to refine a trained model. Pixel ROIs do not contain georeferencing information. They can only be used as input to creating label rasters that are perfectly coregistered with their associated input rasters. If you want to create ROIs that can reproject to a georeferenced raster, use the ClassActivationToPolygonROI task instead.

Example

The file TrainedModelContainers.envi.onnx is included with the ENVI Deep Learning tutorial data, which is available on our ENVI Tutorials web page. Click the "Deep Learning" link in the ENVI Tutorial Data section to download a zip file containing the data. Extract the contents to a local directory. That file is in the shipping_containers directory.

; Start the application

e = ENVI()

 

; Open an input file

File = Filepath('OaklandPortOrthophoto1.dat', $

  Subdir=['data','deep_learning'], Root_Dir=e.Root_Dir)

Raster = e.OpenRaster(File)

ModelFile = 'C:\MyTutorialFiles\TrainedModelContainers.envi.onnx'

Model = ENVIDeepLearningPixelModel(ModelFile)

 

; Run the classification task

ClassTask = ENVITask('DeepLearningPixelClassification')

ClassTask.INPUT_RASTER = Raster

ClassTask.INPUT_MODEL = Model

ClassTask.OUTPUT_CLASS_ACTIVATION_RASTER_URI = e.GetTemporaryFilename()

ClassTask.Execute

 

; Get the task from the catalog of ENVITasks

Task = ENVITask('ClassActivationToPixelROI')

 

; Define inputs

Task.INPUT_RASTER = ClassTask.OUTPUT_CLASS_ACTIVATION_RASTER

 

; Run the task

Task.Execute

 

; Add the output to the Data Manager

e.Data.Add, ClassTask.OUTPUT_CLASS_ACTIVATION_RASTER

 

; Display the result

View = e.GetView()

Layer = View.CreateLayer(Raster)

roiLayer = Layer.AddRoi(Task.OUTPUT_ROI)

Syntax

Result = ENVITask('ClassActivationToPixelROI')

Input parameters (Set, Get): INPUT_RASTER, METHOD, OUTPUT_ROI_URI, THRESHOLD

Output parameters (Get only): OUTPUT_ROI, OUTPUT_THRESHOLD

Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.

Input Parameters

INPUT_RASTER (required)

Specify an input class activation raster.

METHOD (optional)

Specify the thresholding method to use to differentiate feature and background pixels in INPUT_RASTER. This parameter only applies to a single feature class and is ignored for multiple feature classes. If THRESHOLD is specified, it will supersede METHOD. The following are valid values.

OUTPUT_ROI_URI (optional)

Specify a string with the fully qualified path and filename for OUTPUT_ROI.

THRESHOLD (optional)

Specify a threshold value to use to differentiate feature and background pixels in INPUT_RASTER. If the highest feature class value for a given pixel is greater than or equal to the threshold value, the pixel will be designated as that feature class. Otherwise, it will be designated as background. If you set the THRESHOLD parameter, that will supersede METHOD.

Output Parameters

OUTPUT_ROI

This is a reference to the output ROI.

OUTPUT_THRESHOLD

If THRESHOLD is not specified, then this will be the threshold calculated by METHOD. If THRESHOLD is specified, then this will be the threshold specified.

Methods

Execute

Parameter

ParameterNames

See ENVI Help for details on these ENVITask methods.

Properties

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

See the ENVITask topic in ENVI Help for details.

Version History

Deep Learning 1.0

Introduced

Deep Learning 1.1

Modified METHOD and THRESHOLD parameters to allow multiple classes.

See Also

ClassActivationToClassification Task, ClassActivationToPolygonROI Task, ClassActivationToPolygonShapefile Task