Extract One Feature Tutorial Extract Multiple Features Tutorial

Use the TensorFlow Pixel Classification tool to classify a raster using a trained pixel segmentation model. Run this tool as many times as needed to classify multiple rasters. The outputs are classification rasters and class activation rasters.

You can also write a script to classify a raster using the TensorFlowPixelClassification task.

Tip: If you install ENVI® Py for ArcGIS® with ENVI, a TensorFlow Pixel Classification tool will be available for use in the ENVI Deep Learning toolbox folder in ArcMap or ArcGIS Pro. For more information about ENVI Py for ArcGIS, see the Help Article How do I use ENVI Tools in ArcGIS?

Follow these steps:

  1. Open the TensorFlow Pixel Classification dialog using one of the following options:
    • In the Deep Learning Guide Map, click the following button sequence: Pixel Segmentation > Classify Raster Using a Trained Model. The TensorFlow Pixel Classification dialog appears. An advantage of this option is that if you accessed the Deep Learning Labeling Tool through the Guide Map and used it to create label rasters and train a model, the Guide Map knows about the trained model and automatically populates the Input Model field (Step 3 below) with that model file.
    • In the ENVI Toolbox, select Deep Learning > Pixel Segmentation > TensorFlow Pixel Classification.
  2. In the Input Raster field of the TensorFlow Pixel Classification tool, select a raster to classify. It must contain at least as many bands as the raster that was used to train the model.
  3. In the Input Trained Model field, select a trained TensorFlow model file in HDF5 format (.h5).
  4. In the Output Classification Raster field, select a path and filename for the output classification raster (.dat). You must specify this or the Output Class Activation Raster, or both.
  5. Enable the Display result check box to display the output in the view when processing is complete.

  6. In the Output Class Activation Raster field, select a path and filename for the output class activation raster (.dat). This is a grayscale image, one band per feature, that shows the probability of pixels belonging to the features of interest.
  7. Enable the Display result check box to display the output in the view when processing is complete.
  8. To reuse these task settings in future ENVI sessions, save them to a file. Click the down arrow next to the OK button and select Save Parameter Values, then specify the location and filename to save to. Note that some parameter types, such as rasters, vectors, and ROIs, will not be saved with the file. To apply the saved task settings, click the down arrow and select Restore Parameter Values, then select the file where you previously stored your settings.

  9. To run the process in the background, click the down arrow and select Run Task in the Background. If an ENVI Server has been set up on the network, the Run Task on remote ENVI Server name is also available. The ENVI Server Job Console will show the progress of the job and will provide a link to display the result when processing is complete. See the ENVI Servers topic in ENVI Help for more information.

  10. Click OK. ENVI adds the resulting output to the Data Manager and Layer Manager.

Evaluate the Results


The pixel values of the classification raster range from 0 (background) to the number of classes. The following image shows an example of a classification raster. Background pixels are colored black and designated "Unclassified." This example is from the ENVI Deep Learning Tutorial. The classes represent different levels of property damage from a tornado:

Follow these steps to overlay the classification raster over the Input Raster:

  1. Display the Input Raster in the current view.
  2. In the Layer Manager, click and drag the Input Raster below the classification raster.
  3. In the Layer Manager, uncheck the "Unclassified" class.

For example:

You can also display a classification legend by clicking the Annotations drop-down menu in the ENVI toolbar and selecting Legend, then clicking in the display. See the Annotations topic in ENVI Help for more information about changing the properties of the classification legend.

Class Activation Rasters

If you chose to create and display a class activation raster, it is displayed as a color composite of the first three bands and added to the top of the Layer Manager. Uncheck the color composite layer in the Layer Manager, and instead drag the individual bands of the class activation raster from the Data Manager to the view; for example:

Each band of the class activation raster shows the probability (0 to 1) of matching each feature class. Bright pixels indicate high matches to the feature. The following figure shows a small sample of a class activation raster for the "Surface Damage" class (left) displayed next to a true-color image:

A raster color slice helps to visualize the pixels with the highest probability of matching the feature of interest. Follow these steps to create a raster color slice:

  1. Right-click on the class activation raster in the Layer Manager and select New Raster Color Slice. The Data Selection dialog appears.
  2. Select a band in the class activation raster in which to apply a color slice, and click OK. The Edit Raster Color Slices dialog appears. The pixel values are divided into equal increments, each with a different color.
  3. Click OK in the Edit Raster Color Slices dialog to accept the default values and colors.
  4. In the Raster Color Slice layer in the Layer Manager, uncheck the purple and blue color slices to hide them. The remaining colors identify pixels with a high probability of matching the feature of interest, according to the training data you provided. The following image shows an example of a "Structural Damage" band of a class activation raster overlaid on the Input Raster:

Post-Classification Tools

Now that you have a class activation raster, you can optionally apply a threshold to it and convert the highest pixel values to a classification image, pixel ROI, polygon ROI, polyline shapefile, or polygon shapefile.

See Also


Class Activation to Classification, Class Activation to Pixel ROI, Class Activation to Polygon ROI, Class Activation to Polyline Shapefile, Class Activation to Polygon Shapefile, Refine Classification Results