You can use the current ROIs and perform a classification by selecting an algorithm from the Classification →Supervised Classification menu in the ENVI Toolbox.
1. From the ENVI Toolbox expand the Classification and Supervised Classification folders. Then double click on Minimum Distance Classification. A Classification Input File dialog appears. 2. Select ca_coast.dat. Before you click OK click Spectral Subset and then deselect the
thermal band (Band 11). You will not use this band in the classification. Click OK. Note that it is possible to use a mask to exclude areas not to be used in the classification. Click OK again. 3. The Minimum Distance Parameters dialog appears. The ROIs you created from the scatter plot
should be listed. Select them. Next you will set a threshold so that some pixels are unclassified. For Set Max stdev from Mean type in a value of 5. Then click the Preview tab at the bottom of the dialog. The classification preview will be shown in the window on the right side of the dialog. Note that you can click Change View to view another part of the scene.
If you set values for both Set Max stdev from Mean and Set Max Distance Error, the
classification uses the smaller of the two to determine which pixels to classify. If you select None for both parameters, then ENVI classifies all pixels.
4. For Output Classification Filename type Ca_coast_mindist.dat. For Output Rule Filename type Ca_coast_mindist_rule.
5. Click OK to run the classification.
6. The classification result will be displayed. The classification used a tight threshold so most pixels are unclassified (black). In the Layer Manager uncheck Ca_coast_mindist.dat. The
classification result is no longer shown; instead you should see a color composite of rule images (if you have at least three rule images output).
Pixel values in rule images represent how well a particular pixel matched a class training site. Pixel values in rule images for the Minimum Distance classification equal the Euclidean distance from the class mean.
Supervised and Unsupervised Classification Regions of Interest and Classification Techniques
7. To view just one rule image, open the Data Manager, scroll down to a rule image, right click on it and select Load Grayscale.
8. For the Minimum Distance classification the darker areas are the better matches for that class. This is because smaller values correspond to shorter distances to class means. Click on the Custom Stretch icon . You will use this to adjust the contrast stretch for the displayed rule image. 9. When the Custom Stretch histogram tool appears you will see the lower and upper thresholds set to
values inside the tails of the histogram. Because lower values are the better match move the left hand threshold all the way to the left side of the histogram.
10. Set the right-hand threshold to a value on the left side of the plot to make most of the scene go white. Any area that has gray values is a potential match to your class. Click and drag a corner of the Custom Stretch histogram to enlarge it. A larger histogram shows more detail.
Logical places to put the upper threshold are either between histogram peaks or at an abrupt change in histogram slope. Both of these usually occur at the transition between different types of
Regions of Interest and Classification Techniques Supervised and Unsupervised Classification
11. Close the histogram and then right click on the Rule image in the Layer Manager and select Remove.
Next you will use the Rule Classifier to set different thresholds for each class. Classification training sets often have very different data distributions, and using a single threshold for all classes leads to results that are not as accurate as they could be. The Rule Classifier tool allows you to set appropriate thresholds by inspection of rule image histograms.
12. In the ENVI Toolbox expand the Post Classification folder and double click on Rule Classifier. 13. In the Rule Image Classifier dialog, select Ca_coast_mindist_rule and click OK.
14. The first thing to do in the Rule Image Classifier Tool that appears is to decide whether to Classify by Maximum Value or Minimum Value. Because the Minimum Distance algorithm was used to classify this means that smaller pixel values in the rule images indicate a better match. So, toggle Classify by to Minimum Value. Currently in ENVI the only routines where smaller pixel values are the better match are Minimum distance and Spectral Angle Mapper.
15. The classes you defined are listed and checked. The class colors may not correspond with the colors you used to define them. Click Options →Edit class colors/ names. This tool allows you to edit class colors and names. Make any edits that you want. Then click OK to close the Class Color Map Editing dialog.
16. Before setting any thresholds, click Quick Apply to create a new classified image in memory. The image appears in a separate display. Note that the entire image is classified.
17. In the Rule Image Classifier Tool dialog, click the Hist button for the first class. A histogram plot window for the rule image appears. The Rule Image Classifier accesses the same histograms that you viewed previously used the Custom Stretch tool. The histogram shows the distribution (x-axis) and frequency (y-axis) of the pixel distance values from the class mean.
Supervised and Unsupervised Classification Regions of Interest and Classification Techniques
Things you should consider are how abundant and variable the classes are. Materials that are rare in the scene will be found in the tail of the histogram. Materials that are abundant will be represented by a peak.
18. Place your cursor in the histogram and hold the SHIFT key down. If you are inside the plot and not near an axis, the cursor will change into a magnifying glass. While holding the CONTROL key down, click and drag a box in the histogram. To zoom back out, right click in the histogram and choose Reset Plot Range.
19. After zooming in to the histogram, click inside the plot and note Data Values (x-axis) where the slope of the histogram changes. In the example below, possibly threshold values are 44 and 60.
20. Figure out an appropriate threshold for your class and type that value into the Thresh field for the class. Then Click Quick Apply. The temporary result in the separate display will update.
21. Click on the Hist button for each class and determine a good threshold for each. Type your values in to the Tresh field. Then click Quick Apply to evaluate the threshold setting.
Regions of Interest and Classification Techniques Supervised and Unsupervised Classification
22. When you have finished finding good thresholds for all classes save your new result by clicking Save To File on the Rule Classifier Tool.
23. In the Output Rule Classification Filename dialog, type in Ca_coast_class2.dat and click OK.
24. To display the new result, open up the Data Manager, scroll down to your new output, then right click on the Rule Class band for Ca_coast_class2.dat and select Load Grayscale.
25. Close the Rule Image Classifier Tool and the Data Manager.
26. To evaluate your result, right click on the original ca_coast.dat CIR image in the Layer Manager and select Display in Portal. Move the portal around and use the transparency slider or Blend, Flicker, or Swipe to compare your result to the input data set.
Supervised and Unsupervised Classification Regions of Interest and Classification Techniques
27. To convert your classification image to vectors, choose Classification →Post Classification in the ENVI Toolbox. Double click on Classification to Vector. For input select the Rule Class band for Ca_coast_class2.dat and click OK. Select classes to vectorize excluding Unclassified. Toggle Output to One Layer per Class. Type in an output filename of
Ca_coast_class2.evf and click OK.
28. To display the vector files, open up Windows Explorer, browse to your output folder and drag the vector file into the ENVI display. The vectors will be overlain on top of the displayed image. The vector editing tools will be available if you want to make edits.
29. In the Layer Manager, right click on each file except ca_coast.dat and select Remove.
Exercise #3: Classification Workflow
For this classification you will create vectors that define your training sites.
1. From the ENVI Toolbox double click on Classification Workflow. A Classification Input File dialog appears.
2. The file ca_coast.dat should be selected in the Select an Input File dialog. Note that it is possible to use a mask to exclude areas not to be used in the classification. Click Next.
3. In the Select a Method list, select Use Training Data. The No Training Data option is used for an unsupervised classification. Click Next.
4. In the Define Training Data dialog you will see Class 1 after a red box. Click in the Class Name text box and rename the class to soil. In the main ENVI interface, Polygon Annotation is selected. Use the mouse to draw polygons over some bare fields. To finish the polygon, right click and select Accept.
The important things to remember about defining training sites are: the ROIs should only contain one material, and they should encompass the variability of that material. Materials that are very
Regions of Interest and Classification Techniques Supervised and Unsupervised Classification
5. Click on the Add Class icon . Class 2 with a color of green will be added to the list. Rename the class agri then draw some polygons on agricultural fields.
6. Add a few more classes, rename them appropriately, and draw polygons for them. Classes you could consider are rivers, ocean, urban, native vegetation, wetlands, etc. Zoom in to selected areas to help you draw polygons over smaller features.
7. Click the Preview box to bring up a Portal. Resize and move this portal around to evaluate your potential classification result. You may want to add more classes, more ROIs for a particular class, or possibly delete ROIs. To edit a particular ROI, click on the select tool to exit the annotation mode, then click on the ROI itself. You can resize it, move it, or right click and select Delete. 8. Click on the Algorithm tab. Maximum Likelihood is the default. Select Minimum Distance from
the pull-down menu and look at the Preview window to evaluate the potential results. Try other algorithms and note which one seems to provide the best result. Note that you can set thresholds appropriate for each algorithm. And you can choose to have the same threshold apply to all classes or have a different threshold for each class. As in the previous exercise you can select Compute Rule Images and run the Rule Classifier to set new thresholds for each class after the classification has run.
Supervised and Unsupervised Classification Regions of Interest and Classification Techniques
9. When you have finished defining ROIs for several types of land surface materials, save the ROIs. Click on the Save Training Data Set icon , types in a name of Ca_coast_ROIs for the output shapefile, then click OK.
10. Back in the Define Training Data dialog, click Next. The classification will be applied over the whole scene.
11. In the Cleanup step, you can use Smoothing and Aggregation to generalize your classification result by removing small clusters of pixels or merging clusters of one class together. Select Preview and evaluate the potential result of this step. Experiment with different Kernel and Aggregate Sizes. Click Next to perform clean up.
12. In the Export step you specify what output to generate. Let the Export files default; you will export a classification image and classification vectors. Under the Additional Export tab you can output a classification statistics file. Click Export Rule Images if you want to work with the Rule Classifier. Click Finish to generate the output, which will be displayed in the image window.
13. The output files are listed in the Layer Manager. If a Rule image is the top layer, uncheck it so you can see the classification result. Under the color coded classification image is a folder which contains all the classes you defined. Try deselecting some of the classes to see the original image underneath.
Regions of Interest and Classification Techniques Supervised and Unsupervised Classification
14. If you right click on the Classes folder you can turn classes off and on. Right click on the Classes folder and choose Stats for All Classes. Then choose the original input file. The statistics dialog that appears shows the mean spectra of all classes. Near the top of the dialog there is a tab labeled Stats for. Click on the drop-down menu for it and select a class. The stats for that class will be shown in the table below.
15. Click on the Select Plot and Select Stat buttons and choose various items in those lists. This will allow you to become familiar with the options available for this dialog. There are several options available when you right click in the plot window. Right click in the plot window and select Options→ New Window: with Plots. The plots will be displayed in a typical plot window. 16. Close the ENVI Plot Window and the statistics dialog.
17. Right click on the vector layer shapefile and select View Attributes. An Attribute Viewer will appear listing each polygon for all the classes. If you click on a number for a specific polygon, or select several polygons, they will be highlighted in the display.
18. When the Attribute Viewer first appears, the polygons are listed in order of appearance starting in the upper left corner of the image. Click on CLASS NAME to select it, then right click and
experiment with changing the sort order of that column. Click on AREA to select that column, then right click and experiment with changing the sort order. Close the Attribute Viewer.
19. Next you will perform another classification. Remove all the layers except for the ca_coast.dat CIR image.