Tutorial: Object Detection Tutorial

Use the Deep Learning Object Classification tool to classify a raster using a trained ENVI Deep Learning ONNX object detection model. Run this tool as many times as needed to classify multiple rasters. The output is a shapefile of bounding boxes for each class.

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

Follow these steps:

  1. In the ENVI Toolbox, select Deep Learning > Object Detection > Deep Learning Object Classification. The Deep Learning Object Classification dialog appears with the Main tab selected.

    You can also access the Deep Learning Object Classification dialog through the Deep Learning Guide Map with the following button sequence: Object Detection > Object Classification. An advantage of this option is that if you access the Deep Learning Labeling Tool through the Guide Map and use it to create label rasters and train a model, the Guide Map knows about the trained model and automatically populates the Input Model field in the dialog.

  2. In the Input Raster field, 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 Model field, select an ONNX file (.envi.onnx) that has been trained for object detection classification of the input raster.
  4. For the Confidence Threshold, use the slider bar or up/down arrow buttons to specify a threshold value between 0 and 1.0. Bounding boxes with a confidence score less than this value will be discarded before applying the Intersection Over Union Threshold value. The default value is 0.2. Decreasing this value generally results in more classification bounding boxes throughout the scene. Increasing it results in fewer classification bounding boxes.
  5. For the Intersection Over Union Threshold, use the slider bar or up/down arrow buttons to specify a value from 0 to 1.0 indicating the Non-Maximum Suppression Intersection over Union (NMS IOU) value. This is a Deep Learning object detection parameter that reduces detection clustering by pruning bounding boxes that have high IOU with previously selected boxes. The default value is 0.5. Increasing this value results in more overlapping bounding boxes around features. Decreasing the value results in fewer overlapping bounding boxes.
  6. In the Exclude Classes field, specify the class labels to exclude from the output classification results. This will filter out the specified labels to provide a more targeted and customized output.

  7. For Enhance Display, select Yes if you want to apply an additional small stretch to the processed data to suppress noise and enhance feature visibility. The optional stretch is effective for improving visual clarity in imagery acquired from aerial platforms or sensors with higher noise profiles.

  8. For Visual RGB, select Yes if you want to encode the output raster as a three-band RGB composite (red, green, blue) for color image processing. This ensures consistent band selection from ENVI display types (such as RGB, CIR, and pan) and supports integration of diverse data sources (such as MSI, panchromatic, and VNIR) without band mismatch.

  9. In the Output Classification Vector field, select a path and filename for the output shapefile (.shp). The shapefile contains bounding boxes for each class.
  10. To set advanced parameters for processing, select the Advanced tab.
  11. From the Processing Runtime field, select one of the following execution environments for the classification task:

    • CUDA: (Default) Uses NVIDIA GPU acceleration for optimal performance and faster processing
    • CPU: Ensures compatibility on systems without GPU support, but with reduced processing speeds.
  12. Use the CUDA Device ID parameter to explicitly control GPU selection in multi-GPU environments when you choose CUDA as the Processing Runtime. Optionally enter a target GPU device ID. If you provide a valid ID, the classification task will execute on the specified CUDA-enabled GPU. If the ID is omitted or invalid, the system defaults to GPU device 0.

  13. Enable the Display result check box to display the output in the view when processing is complete.
  14. 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.

  15. 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.

  16. Click OK.

Evaluate the Results


Display the output shapefile over the raster that you classified. If the resulting bounding boxes are not satisfactory, you can run the Postprocess Classification Vector tool to try different Confidence Threshold and Intersection Over Union Threshold values without having to run the classification tool again.

To help you determine a more suitable Confidence Threshold, you can view "Confidence" values for individual bounding boxes. To do this, right-click on the shapefile layer in the Layer Manager and select View/Edit Attributes. The Attribute Viewer lists the "Confidence" values for all of the shapefile records (i.e., bounding boxes); for example:

When the shapefile is displayed in the ENVI view, you can draw a box around multiple bounding boxes that you want to evaluate further. From the Attribute Viewer menu bar, select Options > Sort by Current Selection. The corresponding records are highlighted in the Vector Properties dialog so that you can see their confidence values:

In this example with false positives and significant overlap between bounding boxes, the Confidence values range from 0.437 to 0.964. This suggests that you should increase the Confidence Threshold to a higher value, such as 0.8.

See Also


Train Object Detection Models, Post-process Classification Vectors, Object Detection, Deep Learning Grid Classification, Deep Learning Pixel Classification, Deep Learning Optimized Object Classification