Classification Tutorial From ENVI

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Classification Tutorial https://www.l3harrisgeospatial.com/docs/ClassificationTutorial.

html

Welcome to the L3Harris Geospatial documentation center. Here you will �nd reference guides and help documents.

• Docs Center
• IDL Programming
◦ IDL Reference
◦ Using IDL
◦ Modules
▪ Advanced Math and Stats
▪ Dataminer
▪ DICOM Toolkit
◦ Libraries
▪ Astronomy Library
▪ Beaumont Library
▪ Buie Library
▪ Catalyst Library
▪ Coyote Library
▪ Dáithí Library
▪ Galloy Library
▪ JBIU Library
▪ JHUAPLS1R Library
▪ Mankoff Library
▪ Markwardt Library
▪ Motley Library
▪ Salvaggio Library
• ENVI
◦ Using ENVI
◦ Modules
▪ Atmospheric Correction
▪ Crop Science
▪ Deep Learning
▪ DEM Extraction
▪ Feature Extraction
▪ Machine Learning
▪ NITF
▪ Photogrammetry
◦ ENVI API
• Resources
◦ Licensing
◦ PDF Guides
◦ Platform Support

• Docs Center
• IDL ProgrammingIDL Programming
◦ IDL Reference
◦ Using IDL
◦ ModulesModules
▪ Advanced Math and Stats
▪ Dataminer
▪ DICOM Toolkit
◦ LibrariesLibraries
▪ Astronomy Library
▪ Beaumont Library
▪ Catalyst Library
▪ Coyote Library
▪ Dáithí Library
▪ Galloy Library
▪ JBIU Library
▪ JHUAPLS1R Library
▪ Mankoff Library
▪ Markwardt Library
▪ Motley Library
▪ Salvaggio Library
• ENVIENVI
◦ Using ENVI
◦ ModuluesModules
▪ Atmospheric Correction
▪ Crop Science
▪ Deep Learning
▪ DEM Extraction
▪ Feature Extraction
▪ NITF
▪ Photogrammetry
◦ ENVI API
• ResourcesResources
◦ Using ENVI

1 of 8 12/7/22, 16:23
Classification Tutorial https://www.l3harrisgeospatial.com/docs/ClassificationTutorial.html

◦ ModuluesModules
▪ Licensing
▪ PDF Guides
▪ Platform Support
◦ ENVI API

  >  Docs Center  >  Using ENVI  >  Classi�cation Tutorial

Classi�cation Tutorial

Title search... Full search...

In this tutorial, you will use the Classi�cation workflow to categorize pixels in an image into many classes. In the �rst part of the tutorial, you will perform an
unsupervised classi�cation. Unsupervised classi�cation clusters pixels in a dataset based on statistics only and does not use de�ned training classes.

In the second part of the tutorial, you will create training data interactively in the dataset and use it to perform a supervised classi�cation. Supervised classi�cation
clusters pixels in a dataset into classes based on training data that you de�ne. Then you can select the classes that you want mapped in the output.

References

Mahalanobis, Maximum Likelihood, Minimum Distance:

J .A. Richards, 1999, Remote Sensing Digital Image Analysis, Springer-Verlag, Berlin, p. 240.

Spectral Angle Mapper:

Kruse, F. A., A. B. Lefkoff, J. B. Boardman, K. B. Heidebrecht, A. T. Shapiro, P. J. Barloon, and A. F. H. Goetz, 1993, "The Spectral Image Processing System
(SIPS) - Interactive Visualization and Analysis of Imaging spectrometer Data." Remote Sensing of Environment, v. 44, p. 145 - 163.

ISODATA:

Tou, J. T. and R. C. Gonzalez, 1974. Pattern Recognition Principles, Addison-Wesley Publishing Company, Reading, Massachusetts.

Files Used in this Tutorial

Tutorial �les are available from our ENVI Tutorials web page or on the ENVI Resource DVD in the classification directory.

File Description

Phoenix_AZ.tif QuickBird image over Phoenix, Arizona

Performing Unsupervised Classi�cation

The ISODATA method for unsupervised classi�cation starts by calculating class means evenly distributed in the data space, then iteratively clusters the remaining
pixels using minimum distance techniques. Each iteration recalculates means and reclassi�es pixels with respect to the new means. This process continues until
the percentage of pixels that change classes during an iteration is less than the change threshold or the maximum number of iterations is reached.

1. Start ENVI.
2. From the Toolbox, select Classi�cation > Classi�cation Workflow. The File Selection panel appears.
3. Click Browse. The File Selection dialog appears.
4. Click Open File. The Open dialog appears.
5. Navigate to classification, select Phoenix_AZ.tif, and click Open. This is a QuickBird true-color image.
6. Click Next in the File Selection dialog. The Classi�cation Type panel appears.
7. Select No Training Data, which will guide you through the unsupervised classi�cation workflow steps.
8. Click Next. The Unsupervised Classi�cation panel appears.

9. Enter 7 as the Requested Number of Classes to de�ne. You do not need to change any settings on the Advanced tab, so click Next to begin classi�cation.

When classi�cation is complete, the classi�ed image loads in the view and the Cleanup panel appears.

The following is a sample of the unsupervised classi�cation results from part of the image. Your results may be slightly different. Notice the amount of
speckling that occurs within the residential areas:

2 of 8 12/7/22, 16:23
Classification Tutorial https://www.l3harrisgeospatial.com/docs/ClassificationTutorial.html

10. Cleanup is an optional step, but you will use it in this exercise to determine if the classi�cation output improves. The cleanup options are smoothing, which
removes speckling, and aggregation, which removes small regions. In the Cleanup panel, keep the default settings.

11. Enable the Preview option. A Preview Window opens, showing you what the classi�cation cleanup will look like with the current settings. Click on the Preview
Window using the Selection tool (the arrow icon located in the main toolbar), and drag it around the image to see how areas will be affected by cleanup step.

The image below shows that the classi�cation will bene�t from using the Cleanup step. You can see that much of the speckling noise has been replaced with
smoother regions.

12. Click Next. The Export panel appears.


13. Enable only the Export Classi�cation Image check box. Use the default output image type of ENVI, and enter a path and �lename for the classi�cation image.
14. Click Finish.

Next, you will perform supervised classi�cation on the same image. To prepare, do the following:

1. Select File > Data Manager. The Data Manager opens.


2. Select the classi�cation �le that you just created, and click the Close button. Leave the Data Manager and the �le Phoenix_AZ.TIF open.

Performing Supervised Classi�cation

Supervised classi�cation methods include Maximum likelihood, Minimum distance, Mahalanobis distance, and Spectral Angle Mapper (SAM). In this tutorial, you
will use SAM. The SAM method is a spectral classi�cation technique that uses an n-D angle to match pixels to training data. It determines the spectral similarity
between two spectra by calculating the angle between the spectra and treating them as vectors in a space with dimensionality equal to the number of bands.
Smaller angles represent closer matches to the reference spectrum. The pixels are assigned to the class with the smallest angle. When used with calibrated
reflectance data, the SAM method is relatively insensitive to illumination and albedo effects.

1. In the Data Manager, click the Phoenix_AZ.TIF �le. If you have the �le open in ENVI, you can drag the �lename from the Layer Manager to Classi�cation
Workflow in the Toolbox. Or, you can double-click the Classi�cation tool to start it. The File Selection panel appears, with Phoenix_AZ.TIF as the raster
input �le.
2. Click Next in the File Selection panel to proceed. The Classi�cation Type panel appears.
3. Select Use Training Data, which will guide you through the supervised classi�cation workflow steps.
4. Click Next. The Supervised Classi�cation panel appears.
5. Select the Algorithm tab, then select Spectral Angle Mapper from the drop-down list. Keep the default Maximum Spectral Angle setting of None.
6. You can de�ne training data from an existing ROI �le, but for this exercise you will interactively create your own ROIs.

Interactively De�ning Training Data

You will de�ne two classes, with at least one region per class. This is the minimum number of classes required to perform supervised classi�cation.

3 of 8 12/7/22, 16:23
Classification Tutorial https://www.l3harrisgeospatial.com/docs/ClassificationTutorial.html

1. In the Supervised Classi�cation panel, click the Properties tab and change the Class Name �eld from Class #1 to Undeveloped. Leave the Class Color as
red.

2. Locate different areas in the image that are undeveloped. They should not contain buildings or grass, and they should not be roads. Draw polygons inside
three of these areas. To draw a polygon, click in an undeveloped area and hold down the mouse button while drawing, or click the mouse at various points to
mark vertices. When you return the to the starting point of the polygon, double-click to accept it. The ROI is added to Undeveloped layer in the Layer Manager
under the Regions of Interest tree.

The following is an example of one polygon.

3. Click the Add Class button to create a second class.


4. Change the Class Name from Class #2 to Vegetation. Leave the Class Color as green.

5. Locate different areas in the image that display healthy vegetation such as golf courses, trees, lawns, etc. Draw polygons inside three of these areas. The
following zoomed-in image shows an example.

6. Click the Add Class button to create a third class.


7. Change the Class Name from Class #3 to Buildings. Leave the Class Color as blue.

8. Locate different areas in the image that have rooftops. Draw polygons inside three of these areas, preferably rooftops with different brightness levels. The
following zoomed-in image shows an example.

9. Next you will preview the classi�cation results, based on the training data you provided.

Previewing the Classi�cation

1. Enable the Preview option to open a Preview Window that shows the classi�cation result based on the training data you created. The following �gure shows
an example.

4 of 8 12/7/22, 16:23
Classification Tutorial https://www.l3harrisgeospatial.com/docs/ClassificationTutorial.html

The Preview Window shows that roads are being classi�ed as buildings, so you will need to add a fourth class for roads.

2. Disable the Preview option.


3. Click the Add Class button.
4. Change the Class Name from Class #4 to Roads. Leave the Class Color as yellow.
5. Draw polygons within three different road types, including a freeway. You may need to use the Zoom tool in the main toolbar to zoom in enough to draw a
polygon inside a road.
6. Enable Preview again.

7. The Roads training region seemed to do a good job of classifying the roads, but it also reclassi�ed some rooftops that were a shade of gray similar to the
highway. The following image shows an example.

Next, you will delete the Roads region, rename the Buildings region to Developed, and add three road training regions to Developed.

8. Right-click on the Roads class in the Training Data tree, and select Delete Class. The view in the Preview Window updates with the change.
9. Select the Buildings class, and change its Class Name to Developed.
10. Draw polygons within three road sections, being sure to mark at least one section of a highway.

The Preview Window should show that roads and buildings are part of the new Developed class.

Comparing Methods

With the Preview option enabled, try each of the classi�cation methods under the Algorithm tab. For more detailed information on each method, see the references
at the beginning of this tutorial. Here is a brief summary:

Maximum Likelihood assumes that the statistics for each class in each band are normally distributed and calculates the probability that a given pixel belongs to
a speci�c class. Each pixel is assigned to the class that has the highest probability (that is, the maximum likelihood).

5 of 8 12/7/22, 16:23
Classification Tutorial https://www.l3harrisgeospatial.com/docs/ClassificationTutorial.html

Minimum Distance uses the mean vectors for each class and calculates the Euclidean distance from each unknown pixel to the mean vector for each class. The
pixels are classi�ed to the nearest class.

Mahalanobis Distance is a direction-sensitive distance classi�er that uses statistics for each class. It is similar to the maximum likelihood classi�cation, but
assumes all class covariances are equal, and therefore is a faster method. All pixels are classi�ed to the closest training data.

Spectral Angle Mapper (SAM)

6 of 8 12/7/22, 16:23
Classification Tutorial https://www.l3harrisgeospatial.com/docs/ClassificationTutorial.html

It appears that either Maximum Likelihood or Spectral Angle Mapper will provide the best classi�cation results for this image. For this exercise, keep Spectral Angle
Mapper as the algorithm and click Next.

Cleaning Up Supervised Classi�cation Results

When supervised classi�cation is complete, the classi�ed image loads in the Image window, and the Cleanup panel appears. Cleanup is an optional step, but you
will use it in this exercise to determine if the classi�cation output improves. The cleanup options are smoothing, which removes speckling, and aggregation, which
removes small regions.

1. In the Cleanup panel, disable the Enable Smoothing option. Select and keep the default setting for Enable Aggregation.

2. The Preview Window should still be open, showing you a view of what the classi�cation cleanup will look like with the current settings. Click on the Preview
Window, and drag it around the image to see how areas will be affected by cleanup step.

3. Click Next. When the classi�cation process is �nished, the Export panel appears.

Exporting Classi�cation Results

In the Export panel, you can save the classi�cation results to an image, the class polygons to a shape�le, and statistics to a text �le.

To export results:

1. Under the Export Files tab, enable the Export Classi�cation Image option and keep ENVI as the output image type. Enter a valid path and �lename for the
classi�cation image.
2. Enable the Export Classi�cation Vectors option and keep Shape�le as the output vector �le type. Enter a valid path and �lename for the shape�le.
3. Under the Additional Export tab, enable the Export Classi�cation Statistics option. Enter a valid path and �lename for the statistics text �le.

4. Click Finish. ENVI creates the output, opens the classi�cation and vector layers in the Image window, and saves the �les to the directory you speci�ed. You
can view the statistics by opening the �le in a text editor.

5. Select File > Exit to close ENVI.

Product  ENVI

Version   5.6.3

Table of Contents

• What's New in This Release

7 of 8 12/7/22, 16:23
Classification Tutorial https://www.l3harrisgeospatial.com/docs/ClassificationTutorial.html

• Getting Started with ENVI


• Explore Data
• Preprocess Data
• Analyze Data
• Vegetation Analysis
• ENVI Servers
• Visual Programming with ENVI Modeler
• Programming
• Tutorials
• About ENVI
• Preferences

Video Tutorial

Digital Number, Radiance, and Reflectance

Help Article Pick

Floating-point Numbers in IDL


This article discusses frequently asked questions regarding floating-point numbers with respect to their use in IDL.

ABOUT US BLOG FAQ SUPPORT SELF HELP TOOLS DOWNLOADS FORUM

© 2022 L3Harris Geospatial Solutions, Inc. | Legal

My Account    |    Contact Us

8 of 8 12/7/22, 16:23

You might also like