Lab 5: Object Based Classification
Introduction
In this lab we will cover the ENVI object based classification workflow using the Feature Extraction tool.
Learning Outcomes
- Perform Image Segmentation and collect training data for example based feature classification in ENVI
- Use the Classification Wizard in ArcGIS Pro to perform object based classification.
About the Data
The primary data in this lab is a NAIP imager with four spectral bands (RGB NIR) and 0.6m spatial resolution.
Feature Extraction in ENVI
- Download the data for the lab and set a workspace that includes two subfolders one, for original files, and one for final processed files.
Extract the files into your original data folder and open ENVI.
- Open the file xxx. To make the segmentation and classification process quicker we will create a Region of Interest (ROI) to limit the classification to small region. Create an ROI of an area of interest.
- From the Toolbox, select Feature Extraction > Example Based Feature Extraction Workflow. The Data Selection panel appears. In the Input Raster browse and select the NAIP image. In the same window click the Spatial Subset button and use the ROI created in the previous step. Click OK.
![Select Data](../images/data-subset.png)
- Before moving on in the workflow click the Custom Bands tab. This allows you to calculate custom bands that can be used in the segmentation and classification process. Click the Normalized Difference option and select the appropriate bands (Band 1 - Red and Band 4 - NIR for NAIP imagery). Click OK to start the process.
![Custom](../images/ndvi-extraction.JPG)
- The Object Creation panel appears.
This starts the segmentation process. Enable the Preview option. A Preview Window appears, showing the initial segments from the image, colored in green.
- Keep the segmentation method as Edge. Experiment with different bands for segementatio. By default all four of the original bands are used for segmentation, but NIR or NDVI bands may be better for segmentation. Try different Scale and Merge values and see how they impact the segmentation. Try different values until you feel you have delineated the features adequately.
![Segment and Merge](../images/envi-segmentation.png)
- When you are satisfied with the segmentation, click Next. ENVI creates and displays a segmentation image (called the Region Means image in the Layer Manager). Each segment is assigned the mean spectral values of all the pixels that belong to that segment.
Select Training Sample
When segmentation is complete, the Example-Based Classification panel appears with one undefined class (New Class 1). As you move the mouse around the segmentation image, the objects underlying the cursor are highlighted in cyan. You may need to click once on the image to activate this function.
- Disable the Preview option, this will make the process smoother in the beginning.
- In the Class Properties table, change the Class Name to Rooftop and press the Enter key.
- Click on at least 20 different segments that represent rooftops. Try to pick a variety of sizes, shapes, colors, and intensities. The more training samples you select, the better the results from the classification.
The following are some tips for selecting training samples:
-Click again on a segment to remove it from selection.
-If individual segments are hard to discern from each other in certain areas, enable the Show Boundaries option to draw boundaries around each segment.
- If the segmentation image does not provide enough detail to determine if segments represent rooftops (versus a driveway or backyard, for example), uncheck the Region Means image in the Layer Manager. The original image will display instead.
- If you pan or zoom around the image, remember to click the Select icon in the main toolbar before selecting training regions.
- Next, you should define several more classes that are not rooftop. In the Example-Based Classification panel, click the Add Class button . In the Class Properties table, change the new class name to Grass and press Enter. Select Grass in the left side of the panel, then select at least 20 training samples from the image that represent grassy areas such as backyards, fields, and parks.
- Repeat steps 1-3 for the following classes: Concrete (curbs and driveways) and Road (asphalt only). Select at least 20 training samples each, and change the class colors as desired. Add any additional classes as you see fit.
- Save an Example file button , and select an output folder and filename for the training regions you have defined. You can restore this file later if you want to continue where you left off.
- Select the Attributes Selection tab in the Example-Based Classification panel. For this tutorial, you can let ENVI determine the most appropriate attributes to classify with by clicking the Auto Select Attributes button
. After a brief moment, the Selected Attributes column updates to show which attributes will be used. ![](../images/attributes.JPG)
- Use one of the Zoom tools in the toolbar to zoom to 100%. Enable the Preview option in the Example-Based Classification panel. A Preview Window appears with the current classification results. As you make changes to the training data, attributes, and classification settings, the classification results will automatically update. Move the Preview Window around the image or resize it to view results for different areas.
- Disable the Region Means option in the Layer Manager, to hide the segmentation image. The original image will display underneath the Preview Window. Compare the preview classification to the original image.
Black segments are those that the classifier could not determine a suitable class for, so they remain unclassified. The Allow Unclassified option under the Algorithms tab controls whether or not to force all segments into one of the classes you defined.
- If the classification needs improvement you can make adjustments in several ways: Adjust KNN Settings Select the Algorithms tab. Try increasing the Threshold value. The default value is 5 percent, which means segments that have less than 5 percent confidence in each class are set to "unclassified." As you increase the Threshold slider, the classifier will allow more unclassified segments. As you decrease the Threshold slider, the classifier forces more segments into classes, thus creating more opportunity for misclassification. Increase the Neighbors value to 3. A higher value takes into account more neighbors when choosing a target class and should reduce noisy or irrelevant features.
- Collect More Training Samples If Necessary: If you have segments that are persisently being misclassified, you can assign them to known classes by following these steps: Select the Examples Selection tab. On the left side of the Example-Based Classification panel, select the class name that you want to assign the segment to. Ensure that the Select icon is active in the toolbar. In the image display, click on the segment to assign it to the selected class.
- Define a New Class You will probably notice that some trees and grassy areas are incorrectly classified. Try creating a new class called Trees and select training samples for that class: In the Example-Based Classification panel, click the Add Class button . In the Class Properties table, change the new class name to Trees and press Enter. Select Trees in the left side of the panel, then select at least 20 training samples of trees, including their shadows.
- Continue to experiment with these options until you are satisfied with the classification of rooftops. Then click Next. In the next step, you will export a Rooftop class to a raster file.
- The Output panel lets you export various components of the supervised classification to raster images and/or shapefiles. By default, the classification image will include all of the classes that you defined. In the Export Vector tab, check the Export Classification Vectors option. Click the Export Raster tab. Enable the Export Classification Image option, and select an output directory to save the file. Click Finish. ENVI adds a new classification data to the Layer Manager.
-
Review the classes and combine the classes into two broad categories of pervious and impervious (paved/rooftops) surfaces. You can either use the combine classes tool to permanently create a new dataset or simply change the colors of the associated classes.
-
Right click on the classified image and calculate the statistics for the classified results. We will use this data to calculate the percent pervious vs impervious surface in the image. Copy the summary with pixel counts and classes into Excel. Use this data to calculate the percent pervious vs impervious surface.
Object Based Classification in ArcGIS Pro