Lab exercise 11, due right before the next class
GEO5083: Remote Sensing Image Processing and Analysis, UTSA
Student name: ______________
Decision tree based classification
Purpose
This lab is to get familiar with decision tree tool in ENVI. (ENVI has also Neural Network and Support Vector Machine (SVM) tool, it is not required for this lab. But you can practice by yourself if you are interested in).
Step 1. Preparation
The images used in this lab include a subset of a Landsat 5 TM image of Boulder, Colorado. This image has been warped to match a SPOT image that has 10 m pixels, so the Landsat image now has 10m pixels also. You will also use a spatial subset of a USGS DEM that includes the area of the Landsat subset. The elevation image has 30 m pixels. The two images are in different projections, with the Landsat being in State Plane, and the DEM being in UTM. Data (Lab11) can be downloaded from here \\129.115.25.240\XIE_misc\EES5083\
Open two images in ENVI, and make a 3D surface view (see below: band 742) of the image to familiarize you the landscape and topography of the area. If you do not know how to do a 3D surface view, please refer to labs of the remote sensing class.

3D perspective view of Boulder, Colorado
Step 2. Build your decision tree
1. Start the decision tree tool by choosing
Classification → Decision Tree → Build New Decision Tree.2. The first decision will be based on the Landsat image. To define the decision, click on the decision node, which is currently labeled
Node 1. In the resulting Edit Decision Properties dialog, enter the following expression: {ndvi} gt 0.33. In the Name field enter:
NDVI>0.3. This is the text that will appear on the decision node in the graphical view of the decision tree. Click the OK button and notice that the name of Node 1 has changed.4. In the Variables/Files Pairing dialog that has just appeared, click on the name of the
{ndvi} variable. In the resulting file selection dialog, choose the bouldr_tm.dat image. This step tells the decision tree that when evaluating this decision expression, the NDVI values should be calculated from the bouldr_tm.dat image.(This is now a very simple decision tree classifier. Pixels with NDVI greater than 0.3 will be included in the white class (Class 1), and pixels with NDVI less than or equal to 0.3 will be included in the black class (Class 0). In the following steps you will enter additional decision rules to develop a more complicated classification)
5. Subdivide the pixels with high NDVI into subcategories by right-clicking on the
Class 1 node and selecting Add Children from the shortcut menu that appears. ENVI automatically creates two new classes beneath Class 1 (now-blank node)6. Click on the now-blank node, and enter the following decision in the Edit Decision Parameters dialog:
{slope} lt 20. This decision will divide the high NDVI pixels based on the steepness of the slope.7. For the name of this node, enter
Slope<20. Click OK.8. Right-click on the green terminal node (now Class 2), which will include pixels with high NDVI and low slopes, and select
Add Children from the shortcut menu that appears. Click on the node and enter the following expression in the Edit Decision Parameters dialog: {aspect} lt 20 or {aspect} gt 340. This decision will divide the high NDVI and low slope pixels into those with north-facing aspects and those without strongly north-facing aspects. For the name of this node, enter North. Click OK.9. Right-click on the black terminal node (Class 0), which will include pixels with low NDVI values, and choose
Add Children from the shortcut menu. In the Edit Decision Properties dialog, enter the following expression: b4 lt 20. Pixels with values less than 20 in band 4 will mainly correspond to water. For the name of this node, enter Low B4. Click OK.10. In the Variables/Files Pairing dialog, click on the name of the variables to pair the following variables and files or bands
{b4}
= bouldr_tm.dat band 4{slope}
= Boulder_dem.dat{aspect}
= Boulder_dem.dat


Step 3. View your decision tree results
11. The color of a given pixel in the output from the decision tree is determined by the color of the terminal node into which that pixel is classified. Thus, for example, the yellow pixels in the decision tree result are the pixels that answered no at every decision point. So, they have low NDVI values and high values in band 4. This means that they are not water and they are not vegetation.
Now, that you have executed the decision tree, take another look at the tree itself; the default view does not include all of the information that could be shown. In the blank background area of the ENVI Decision Tree dialog, right-click and select Zoom In from the shortcut menu that appears. Now each node label displays the number of pixels and the percentage of the entire image that progressed to each node of the tree.
In this case, when the decision tree is expanded, the entire tree no longer fits into the window. You can resize the window by clicking with the left mouse button and dragging a corner of the window.
Place the cursor over any node, and notice that information about that node appears in the text field at the bottom of the ENVI Decision Tree dialog. This is another useful way to quickly get information about nodes in the tree, especially when the tree view is not zoomed in to show node details.
Step 4. Modify your decision tree
After you have executed a decision tree and examined the results, you may find that additional decision rules may be useful. For example, in this decision tree some of the pixels with band 4 values below 20 are the border pixels (outside of the real image), which all have values of 0. They’re showing up as cyan because their values are below 20, but really they have low band 4 values for a completely different reason that the other cyan pixels.
12. Right-click on the terminal node for pixels with band 4 values below 20, and select Add Children from the shortcut menu. Click on the node and enter the following expression in the Edit Decision Parameters dialog: b4 eq 0. In the Name text box, enter B4 = 0.
13. Execute the tree again by right-clicking in the dialog background and choosing Execute from the shortcut menu. In the output image, the border pixels are now in their own class, but the magenta border looks strange.
14. Click on the magenta terminal node to display the Edit Class Properties dialog. Click the V button (or a down-arrow on UNIX) to display a list of colors and select Black. In the Name text box, enter Border.
15. To apply the color change to the tree result, execute the tree again. Your tree and image should look like below.


16. Right-click on the yellow terminal node, which includes pixels with low NDVI values but high band 4 values, and select Add Children from the shortcut menu. Click on the node and enter the following expression in the Edit Decision Parameters dialog: b1 lt {mean[1]} . In the Name text box, enter Low B1. Click OK.
This expression asks whether the pixels have a value in band 1 less than the mean value for band 1. The “1” inside the square brackets indicates that band 1 is to be used for the mean calculation. Some of the variables that ENVI is able to calculate on-the-fly for decision trees, including the mean calculation, have to be associated with a whole file rather than individual bands. In those cases you need to specify which band in the file you want to use for the calculation, in square brackets.
17. In the Variable/File Pairings dialog, click on the b1 variable, and in the resulting file selection dialog, choose Band 1 of bouldr_tm.dat, then click OK. In the Variable/File Pairings dialog, click on the {mean} variable, choose the bouldr_tm.dat file, then click OK. Now both the b1 variable, and the {mean} variable are paired with Band 1 from the Landsat image.
18. To apply the change to the decision tree, execute the tree again and watch the resulting change: some of the yellow pixels that have low Band 1 values are now magenta.
Step 5. Other operations in decision tree
Prune Decision Tree:
Often when using decision tree, it is desirable to test whether a specific set of children are useful additions to a tree. ENVI’s Decision Tree tool provides two methods for removing children once they have been added. Using the
Delete option permanently removes the children from the tree, while using the Prune option temporarily removes them and allows them to be reinstated without redefining the decision rule or node properties.19. Right-click on the Low B1 node and select Prune Children from the shortcut menu that appears. Notice that, while the children are still visible, they are no longer colored nor connected to the tree. This indicates that they have been pruned, and will not be used when the tree is executed.
Right-click on the Low B1 node and select Restore Pruned Children from the shortcut menu. Pruning and restoring the children allows you to compare the tree results with and without particular sets of children.
Save Tree Survivors to a Mask
20. Right-click the red node in the decision tree, and select
Save Survivors to Mask from the shortcut menu. This option will make a binary mask image that assigns a value of 1 to pixels that are included in that class and a value of 0 to pixels that are not included in that class. In the resulting Output Survivors to Mask dialog, enter an output filename for the survivor mask, then click OK. The resulting mask image is listed in the Available Bands List. Load the new mask image into a new gray scale display. Notice that the white pixels in the mask correspond to the red pixels in the decision tree output image.Save the Decision Tree
It is possible to save decision trees, including all of the pairings between variables and files. Saving a decision tree allows you to restore it in a later ENVI session.
21. From the decision tree view, choose
File → Save Tree. In the resulting Save Decision Tree dialog, enter an output filename for the tree, then click OK.
Finally you got seven classes:
• Class 1: NDVI above 0.3, slope greater than or equal to 20 degrees
• Class 2: NDVI above 0.3, slope below 20 degrees, non-north-facing aspect
• Class 3: NDVI above 0.3, slope below 20 degrees, north-facing aspect
• Class 4: NDVI less than or equal to 0.3, band 4 greater than or equal to 20
• Class 5: NDVI less than or equal to 0.3, band 4 below 20
• Class 6: band 4 equal to 0 (Border)
• Class 7: band 1 less than the mean of band 1
Report your procedure, make a 3D surface map using your classified image overlaying the DEM, and make a final (GIS) map with all map elements