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 TensorFlowMaskClassification task.
Tip: If you install ENVI® Py for ArcGIS® version 1.3 with ENVI 5.5 Service Pack 2 or later, a TensorFlow Mask 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:
- 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.
- 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.
- In the Input Model field, select a trained TensorFlow model file in HDF5 format (.h5).
- 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.
Enable the Display result check box to display the output in the view when processing is complete.
- In the Output Class Activation Raster field, select a path and filename for the output class activation raster (.dat). This is a greyscale image, one band per feature, that shows the probability of pixels belonging to the features of interest.
- Enable the Display result check box to display the output in the view when processing is complete.
To reuse these task settings in future ENVI sessions, save them to a file. Click the down arrow 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.
To run the process on a local or remote ENVI Server, click the down arrow and select Run Task in the Background or Run Task on remote ENVI Server name. 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.
- Click OK. ENVI adds the resulting output to the Data Manager and Layer Manager.
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:
- Display the Input Raster in the current view.
- In the Layer Manager, click and drag the Input Raster below the classification raster.
- In the Layer Manager, uncheck the "Unclassified" class.
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:
- Right-click on the class activation raster in the Layer Manager and select New Raster Color Slice. The Data Selection dialog appears.
- 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.
- Click OK in the Edit Raster Color Slices dialog to accept the default values and colors.
- 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:
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.
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