You are on page 1of 195

Exploring ENVI

Copyright 2012
E3De, ENVI and IDL are trademarks of Exelis, Inc. All other marks are the property of their
respective owners. 2012, Exelis Visual Information Solutions, Inc.

Produced by Outreach Services


Exelis Visual Information Solutions
4990 Pearl East Circle
Boulder, CO 80301
303-786-9900

ii

Exploring ENVI

Contents

Contents
INTRODUCTION ........................................................................................................................................................... 1
WHAT IS ENVI? ................................................................................................................................................................. 2
ENVI RESOURCES.............................................................................................................................................................. 2
ABOUT THIS TRAINING MANUAL ....................................................................................................................................... 4
MASTERING THE BASICS .......................................................................................................................................... 5
LEARNING OBJECTIVES ...................................................................................................................................................... 6
PREREQUISITES .................................................................................................................................................................. 6
REQUIRED TOOLS FOR COMPLETING THIS MODULE........................................................................................................... 6
ASSOCIATED DATA ............................................................................................................................................................ 6
FUNDAMENTALS ................................................................................................................................................................ 6
SETTING PREFERENCES AND DISPLAY MANAGEMENT ....................................................................................................... 8
EXPLORING THE ENVI INTERFACE................................................................................................................................... 12
WORKING WITH A PORTAL, AND BLEND, FLICKER, AND SWIPE........................................................................................ 18
CHIPPING AND SAVING ..................................................................................................................................................... 19
SPECTRAL PROFILES ......................................................................................................................................................... 20
ENVI HELP ...................................................................................................................................................................... 21
MORE ON SETTING PREFERENCES .................................................................................................................................... 22
SPATIAL AND SPECTRAL SUBSETTING .............................................................................................................................. 23
CLOSING FILES ................................................................................................................................................................. 26
SKILLS CHECK.................................................................................................................................................................. 26
SELF TEST ........................................................................................................................................................................ 26
RASTER DATA MANAGEMENT ............................................................................................................................. 27
LEARNING OBJECTIVES .................................................................................................................................................... 28
PREREQUISITES ................................................................................................................................................................ 28
REQUIRED TOOLS FOR COMPLETING THIS MODULE......................................................................................................... 28
ASSOCIATED DATA .......................................................................................................................................................... 28
READING RASTER IMAGE DATA ....................................................................................................................................... 28
ENVIS IMAGE FORMAT .................................................................................................................................................. 29
THE ENVI HEADER FILE .................................................................................................................................................. 29
MANAGING FILES ............................................................................................................................................................. 35
SKILLS CHECK.................................................................................................................................................................. 36
SELF TEST ........................................................................................................................................................................ 36
IMAGE DISPLAY CONCEPTS .................................................................................................................................. 37
LEARNING OBJECTIVES .................................................................................................................................................... 38
PREREQUISITES ................................................................................................................................................................ 38
REQUIRED TOOLS FOR COMPLETING THIS MODULE......................................................................................................... 38
ASSOCIATED DATA .......................................................................................................................................................... 38
STRETCHING IMAGE DATA ............................................................................................................................................... 38
COLOR TABLES ................................................................................................................................................................ 42
RASTER COLOR SLICES .................................................................................................................................................... 44
SKILLS CHECK.................................................................................................................................................................. 48
SELF TEST ........................................................................................................................................................................ 48
EXAMPLE APPLICATION: VEGETATION ANALYSIS ...................................................................................... 49
LEARNING OBJECTIVES .................................................................................................................................................... 50
PREREQUISITES ................................................................................................................................................................ 50
REQUIRED TOOLS FOR COMPLETING THIS MODULE......................................................................................................... 50
ASSOCIATED DATA .......................................................................................................................................................... 50
PREPROCESSING ............................................................................................................................................................... 50

Exploring ENVI

iii

Contents

DARK SUBTRACTION ........................................................................................................................................................53


TOPOGRAPHIC MODELING ................................................................................................................................................56
IMAGE TO IMAGE REGISTRATION ......................................................................................................................................57
BUILDING MASKS .............................................................................................................................................................59
NORMALIZED DIFFERENCE VEGETATION INDEX (NDVI) .................................................................................................61
STATISTICS .......................................................................................................................................................................62
3D SURFACEVIEW ............................................................................................................................................................63
SKILLS CHECK ..................................................................................................................................................................68
SELF TEST.........................................................................................................................................................................68
VECTOR LAYERS .......................................................................................................................................................69
LEARNING OBJECTIVES .....................................................................................................................................................70
PREREQUISITES .................................................................................................................................................................70
REQUIRED TOOLS FOR COMPLETING THIS MODULE .........................................................................................................70
ASSOCIATED DATA ...........................................................................................................................................................70
WORKING WITH VECTORS IN ENVI ..................................................................................................................................70
IMAGE REPROJECTION ......................................................................................................................................................71
EDITING VECTOR LAYERS ................................................................................................................................................72
LINEAR FEATURE EXTRACTION ........................................................................................................................................74
SKILLS CHECK ..................................................................................................................................................................78
SELF TEST.........................................................................................................................................................................78
REGIONS OF INTEREST AND CLASSIFICATION TECHNIQUES ...................................................................79
LEARNING OBJECTIVES .....................................................................................................................................................80
PREREQUISITES .................................................................................................................................................................80
REQUIRED TOOLS FOR COMPLETING THIS MODULE .........................................................................................................80
ASSOCIATED DATA ...........................................................................................................................................................80
2D SCATTER PLOT AND REGIONS OF INTEREST ................................................................................................................80
SUPERVISED AND UNSUPERVISED CLASSIFICATION ..........................................................................................................83
TERRAIN CATEGORIZATION ............................................................................................................................................100
SKILLS CHECK ................................................................................................................................................................107
SELF TEST.......................................................................................................................................................................107
PRINCIPAL COMPONENTS ANALYSIS ...............................................................................................................109
LEARNING OBJECTIVES ...................................................................................................................................................110
PREREQUISITES ...............................................................................................................................................................110
REQUIRED TOOLS FOR COMPLETING THIS MODULE .......................................................................................................110
ASSOCIATED DATA .........................................................................................................................................................110
INTRODUCTION ...............................................................................................................................................................110
SKILLS CHECK ................................................................................................................................................................115
SELF TEST.......................................................................................................................................................................115
SPECTRAL LIBRARIES AND HYPERSPECTRAL PROCESSING TOOLS ....................................................117
LEARNING OBJECTIVES ...................................................................................................................................................118
PREREQUISITES ...............................................................................................................................................................118
REQUIRED TOOLS FOR COMPLETING THIS MODULE .......................................................................................................118
ASSOCIATED DATA .........................................................................................................................................................118
INTRODUCTION ...............................................................................................................................................................118
SEQUENTIAL MAXIMUM ANGLE CONVEX CONE (SMACC) ...........................................................................................118
WORKING WITH SPECTRAL LIBRARIES ...........................................................................................................................123
SPECTRAL ANGLE MAPPER (SAM) CLASSIFICATION ......................................................................................................124
SKILLS CHECK ................................................................................................................................................................131
SELF TEST.......................................................................................................................................................................131
EXTENDING ENVI ....................................................................................................................................................133
LEARNING OBJECTIVES ...................................................................................................................................................134

iv

Exploring ENVI

Contents

PREREQUISITES .............................................................................................................................................................. 134


REQUIRED TOOLS FOR COMPLETING THIS MODULE....................................................................................................... 134
ASSOCIATED DATA ........................................................................................................................................................ 134
INTRODUCTION............................................................................................................................................................... 134
BAND AND SPECTRAL MATH .......................................................................................................................................... 135
TIPS FOR WRITING EXPRESSIONS ................................................................................................................................... 136
BATCH PROCESSING IN ENVI ........................................................................................................................................ 148
LIBRARY ROUTINES ....................................................................................................................................................... 151
ENVI EXTENSIONS ........................................................................................................................................................ 155
SKILLS CHECK................................................................................................................................................................ 161
SELF TEST ...................................................................................................................................................................... 161
COLOR TRANSFORMS AND DATA FUSION TECHNIQUES .......................................................................... 163
LEARNING OBJECTIVES .................................................................................................................................................. 164
PREREQUISITES .............................................................................................................................................................. 164
REQUIRED TOOLS FOR COMPLETING THIS MODULE....................................................................................................... 164
ASSOCIATED DATA ........................................................................................................................................................ 164
INTRODUCTION............................................................................................................................................................... 164
COLOR TRANSFORMS ..................................................................................................................................................... 165
IMAGE TO IMAGE REGISTRATION ................................................................................................................................... 168
DATA FUSION USING COLOR TRANSFORMS .................................................................................................................... 170
SKILLS CHECK................................................................................................................................................................ 171
SELF TEST ...................................................................................................................................................................... 172
FEATURE EXTRACTION ........................................................................................................................................ 173
LEARNING OBJECTIVES .................................................................................................................................................. 174
PREREQUISITES .............................................................................................................................................................. 174
REQUIRED TOOLS FOR COMPLETING THIS MODULE....................................................................................................... 174
ASSOCIATED DATA ........................................................................................................................................................ 174
FEATURE EXTRACTION WORKFLOW .............................................................................................................................. 174
EXTRACTING DARK ROOFTOPS WITH RULE-BASED CLASSIFICATION ............................................................................ 175
SKILLS CHECK................................................................................................................................................................ 183
SELF TEST ...................................................................................................................................................................... 183
MOSAICKING IN ENVI............................................................................................................................................ 185
LEARNING OBJECTIVES .................................................................................................................................................. 186
PREREQUISITES .............................................................................................................................................................. 186
REQUIRED TOOLS FOR COMPLETING THIS MODULE....................................................................................................... 186
ASSOCIATED DATA ........................................................................................................................................................ 186
INTRODUCTION............................................................................................................................................................... 186
SKILLS CHECK................................................................................................................................................................ 189
SELF TEST ...................................................................................................................................................................... 189

Exploring ENVI

Introduction

What is ENVI? ............................................................................................................................ 2


ENVI Resources......................................................................................................................... 2
About this Training Manual ......................................................................................................... 4

Exploring ENVI

Introduction

What is ENVI?

ENVI (the Environment for Visualizing Images) is the ideal software for the visualization, analysis, and
presentation of all types of digital imagery. ENVIs complete image-processing package includes advanced,
yet easy-to-use, spectral tools, geometric correction, terrain analysis, radar analysis, raster and vector GIS
capabilities, extensive support for images from a wide variety of sources, and much more.

ENVI can be used to perform numerous image analysis techniques, including multispectral classification,
various types of spatial filtering, image registration, principal components transformations, band ratios, and
image statistics. ENVI also has a unique suite of advanced spectral analysis tools designed specifically for
working with hyperspectral data (although many are also appropriate for multispectral analysis) and a
complete set of tools for working with radar data (both single band and fully polarimetric SAR).
Furthermore, ENVI provides full access to the programming language in which it was written: the
Interactive Data Language (IDL)a powerful, yet easy to use, fourth-generation language whose programs
can easily be incorporated into ENVI.
ENVIs interactive analysis capabilities include:
Multiple views capability allows you to easily compare images.
Real-time extraction and linked spatial/spectral profiling from multi-band and hyperspectral data
that provide you with new ways of looking at high-dimensional data.
Interactive tools to view and analyze vectors and GIS attributes.
Standard capabilities, such as contrast stretching and 2D scatter plots.

ENVI + IDL, ENVI, and IDL

ENVI is enhanced by coupling it with Interactive Data Language (IDL ), a powerful structured
programming language that offers integrated image processing. The flexibility of ENVI is due largely to
IDLs capabilities.

There are two types of ENVI licenses:


ENVI + IDL ENVI plus a full version of IDL
ENVI ENVI plus a runtime version of IDL
ENVI + IDL users can use IDL to customize their own command-line functions. Advanced ENVI + IDL
users should find the flexibility offered by IDLs interactive features helpful for their dynamic image
analyses.

ENVI Resources
Exelis Visual Information Solutions has a team of Professional Services Group (PSG) consultants who
provide custom software development; consulting services; and training to commercial, research, and
government markets. The PSG team can either help you define requirements and lead your development
cycle from prototyping to final installation, or they can join your project mid-stream and provide expert
assistance.
Each PSG team member offers expertise in areas such as image processing; data analysis; visualization;
software development; a broad range of scientific application areas; and government civilian, defense, and
intelligence community requirements. If needed, some staff have the necessary security clearances to
support classified projects.

Exploring ENVI

Introduction

The PSG team is experienced in extending ENVIs robust suite of user functions and batch programming
capabilities, and it has up-to-date knowledge on recent product enhancements and future product direction.
You can e-mail the Global Services Group at sales@exelisvis.com.

Contacting Exelis Visual Information Solutions


Call, email, or visit us online:
Exelis Visual Information Solutions
4990 Pearl East Circle
Boulder, CO 80301 USA
Phone: 303-786-9900
Fax: 303-786-9909
Email: sales@exelisvis.com
Web: www.exelisvis.com

Training
Exelis Visual Information Solutions offers a full range of IDL and ENVI training courses for
everyone from the beginning user to the experienced application developer. We teach courses on a
rotating basis at our training facility in Boulder, Colorado. We also offer regional training classes
every year at various locations in the United States, Europe, and Australia. For the latest training
schedule, a detailed course outline, and/or the cost of a training course, call, send e-mail
(training@exelisvis.com), or go online.

Tutorials
A number of ENVI tutorials are available on the ENVI website
(www.exelisvis.com/ProductsServices/ENVI/Tutorials.aspx) and on the data CDs that shipped with
your ENVI software.

ENVI Support
If you experience a problem with ENVI, first verify that the issue is not a result of misinterpreting the
expected outcome of a specific function or action. Double-check the ENVI Help, or check with a local
expert. Make sure your system is properly configured with enough virtual memory and sufficient operating
system quotas.
If the problem still occurs, report it to Technical Support quickly, so that the issue can be resolved, or a
workaround can be provided. If you cannot find the information you need in the ENVI written guides or
Help, report this to Technical Support as well, so that the documentation can be updated.

Contacting Technical Support


To report a problem, call, e-mail, or go online to submit a support incident:
Phone: 303-413-3920
Email: support@exelisvis.com

Online Resources
There are two additional resources for ENVI support: the Exelis Visual Information Solutions website and
the IDL newsgroup.

Website
The Exelis Visual Information Solutions website has several links that provide additional ENVI

Exploring ENVI

Introduction

support. The website includes access to user-contributed ENVI code, an ENVI user forum, an IDL
user forum, and help articles. Go to www.exelisvis.com, select Support or User Community, then
select an option.
ENVI tutorials and web seminars are also available on the ENVI website. Go to
www.exelisvis.com, then select an option.

IDL Newsgroup
The Usenet newsgroup comp.lang.idl-pvwave is dedicated to the discussion of IDL. Users post
questions and answers and share information about their own IDL projects. Note that many Exelis
Visual Information Solutions employees read this newsgroup, but they do not usually post messages
to the group.

About this Training Manual


This is a training manual used to teach customers ENVI. It is designed to be a classroom training aid.
However, if you cannot attend a training course, this manual is the next best tool for quickly learning and
understanding ENVI.
We want you to learn ENVI and apply it successfully to your work. If you have any suggestions for
improvements or additions to this manual, please let us know.
Most chapters in this manual are self-contained. In most cases you can pick up the manual in any particular
functional area and start working with the exercise immediately.

Bold

All ENVI menu options, dialog buttons, dialog fields, other dialog options,
and values that you need to enter are bold.

Courier

Filenames, directory paths, and IDL/ENVI programming variables are in a


Courier font.

Numbered Steps

Paragraphs beginning with a bold number designate commands that need to


be performed for a particular exercise.

Exploring ENVI

Chapter 1:

Mastering the Basics


Learning Objectives.................................................................................................................... 6
Fundamentals ............................................................................................................................ 6
Setting Preferences and Display Management ........................................................................... 8
ENVI Help ................................................................................................................................ 21
More on Setting Preferences .................................................................................................... 22
Spatial and Spectral Subsetting ............................................................................................... 23
Closing Files ............................................................................................................................ 26
Skills Check ............................................................................................................................. 26
Self Test ................................................................................................................................... 26

Exploring ENVI

Mastering the Basics

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Use ENVI to display a multispectral image
Enhance, zoom, pan, and rotate the image
Create a Portal and compare it to the original scene using blend, flicker, and swipe tools
Use Chip View To to take a screen capture of the image and save it to JPEG format
Change ENVI Preferences

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

qb_boulder_msi Quickbird image of Boulder, Colorado that comes with the ENVI
installation.
New_Zealand_WV2.dat WorldView2 data set of New Zealand.

Fundamentals
The ENVI interface provides quick access to common display tools such as contrast stretching, brightness,
sharpening, and transparency. You can work with multiple layers of data at one time and in several windows
or views, using the Data Manager and Layer Manager to keep track of multiple data sets. ENVIs Portal
capability allows you to punch through layers to view and work with other layers below. In addition,
ENVI will reproject and resample images on-the-fly. ENVIs Toolbox contains many of the popular image
processing tools.

Exercise #1: Starting ENVI and Exploring the Toolbox


1. In Windows, start a new ENVI session by clicking Start All Programs ENVI x.x
ENVI+IDL. If you are working on a UNIX machine, then type envi at the UNIX prompt.
2. In ENVI + IDL, the IDL Workbench window (the control panel for the IDL session that is running
ENVI) is minimized at the bottom of the screen. This window (Figure 1) is only used for advanced
techniques involved with customizing and extending ENVI but must be open to run ENVI + IDL. If
you are running ENVI (vs. ENVI + IDL), access to the IDL Workbench is not provided, and
therefore, the window is not displayed.
If you are working on a UNIX machine, the IDL Workbench window is automatically opened.

Exploring ENVI

Fundamentals

Mastering the Basics

Figure 1: IDL Workbench Window

Exploring ENVI

Mastering the Basics

Setting Preferences and Display Management

3. Once ENVI loads, you will see the single window interface (Figure 2). This is the primary control
panel for working in ENVI, allowing you to do such things as open files and apply processing
functions.

Figure 2: The ENVI Interface

4. Explore the options available in the ENVI Toolbox on the right side of the interface. There are
literally hundreds of different tools available from this menu. Expand the categories by clicking on
the plus symbol for them. Try to get an overview of what tools are available in each category.
Note the location of the following tools:
Edit ENVI Header is under the Raster Management menu
Building masks falls under Raster Management Masking
Principal Components Analysis (PCA) is under the Transform menu
5. At the top of the Toolbox list is Favorites. This is useful for quickly accessing tools you use often.
To add a tool, click on it to select it and the large plus sign above the list will be clickable. Click on
it to add that tool to your list of favorites. You can remove a tool from the list of favorites by
selecting it and clicking the large minus sign.

Setting Preferences and Display Management


Opening files and displaying images is perhaps the most basic, yet fundamentally important task for image
processing software. By default when you open a file, ENVI attempts to automatically display a true color
or gray scale image based on your file type. In this exercise, you will change this preference. Displaying

Exploring ENVI

Setting Preferences and Display Management

Mastering the Basics

images in ENVI is simplified as much as possible by building in support for the most common data formats
and by making a special control panel (Display Manager) dedicated to managing open files and creating
layers of imagery. ENVI uses the red, green, blue (RGB) color display standard. This standard allows 256
levels of brightness (i.e., byte scale) in each channel (red, green, and blue) for each pixel. ENVI can display
numeric data of any format (for example, floating-point temperature/thermal data), but to actually put those
data on the screen as an image, it must be scaled to the 256 brightness values to be understood by the
monitor. Fortunately, ENVI can do this with minimal user input.

Exercise #2: Setting Preferences and Displaying Images


Much of the ENVI interface and system-wide defaults are configurable. You can customize the ENVI
configuration and save the changes as .sav files. For a Windows 7 installation, the ENVI preferences files
are stored in this folder: C:\Users\username\.idl\envi\preferencesx_x-36-osname-bits\,
where x_x is the software version osname is the operating system, and bits is 32 or 64.
1. From the ENVI menu bar, select File Preferences. The ENVI Preferences dialog appears.
2. On the left side of the dialog, select Data Manager.
3. On the right side of the dialog, click the Auto Display Method for Multispectral Files field and
select CIR (color infrared) from the pull-down menu. This will cause image files to be displayed as
color infrared by default.
4. Look at all the options for the Data Manager and ensure the following settings are selected:

Auto Display Files On Open = True

Clear View When Loading New Image = False

Close Data Manager After Loading New Data = False.

5. Select Directories from the left side of the dialog and then click on the Output Directory field.
Click on the pull-down menu and navigate to C:\ENVI_coursefiles\envidata\enviout
and click OK to make this the output directory.

Exploring ENVI

Mastering the Basics

Setting Preferences and Display Management

6. Click OK to close the Preferences dialog.


7. From the ENVI main menu bar, select File Open.
8. With a default installation, ENVI looks for data in the Program
Files..\Exelis\ENVIxx\data directory, where xx is the software version number. Select
the file qb_boulder_msi from the list, and click Open. The image is automatically displayed as
color-infrared (CIR). You can also find data in the Program
Files..\Exelis\ENVIxx\classic\data directory.
9. Click on the Data Manager icon . The Data Manager lists the files that you have opened and
allows you to select bands to display. When you open a file in ENVI, it is added to the top of the
Data Manager list.
10. When you click on band names in the Data Manager, color assignments automatically cycle through
red, green, then blue (in that order). Click the band name you want to assign to red. A red box
appears next to the band name.
11. Select two other bands for green and blue. If one band is assigned multiple colors, a split box
appears next to the band name, showing the colors. Click Load Data to see the new band
combination.

10

Exploring ENVI

Setting Preferences and Display Management

Mastering the Basics

12. Right-click on the filename qb_boulder_msi and select Load True Color. ENVI looks for
wavelength information in the header file to select which bands will make a true-color. The option
to load a True Color or CIR image using the right-click menu requires that the bands in the file have
wavelength information associated with them.
13. Right-click on one of bands of qb_boulder_msi and select Load GrayScale.
14. Click the Help icon
at the bottom of the Data Manager. Scroll down a bit in Help and note that
you can load a specific band as a grayscale image by right-clicking on that band and selecting Load
Grayscale. Close the ENVI Help by clicking the X at the top right of the dialog window.
You will find quick access to helpful tips throughout ENVI. ENVI Help is also accessible via the
Help menu.
15. Click on the File Information arrowhead in the Data Manager. Useful information found here
includes file size and dimensions, data type, and map projection.
16. Click on Band Selection in the Data Manager. This is another tool you can use to select bands to
display. The red button is currently the active one, so any band you click on will be placed there.
Then the Green button will be active.
17. Position your mouse cursor over the toolbar buttons at the top of the Data Manager to view their
pop-up labels. Note that you can open new files, expand and collapse files (experiment with these),
close files, and pin the Data Manager to keep it on the screen or unpin it to have it automatically
close when you load an image into the display. There is also a button to open a file in ArcMap.
18. Close the Data Manager by clicking the X on the top right of the dialog window.

Exercise #3: Working with Layers and Multiple Views


Exploring ENVI

11

Mastering the Basics

Exploring the ENVI Interface

You can load multiple layers into ENVI at one time and manage those layers using the Layer Manager. By
default, all layers in the Layer Manager are displayed in the Image window. You can temporarily hide the
display of a layer so that you can work with other layers in the Image window. You can control the order
of layers in the Image by dragging and dropping layers in the Layer Manager list or by using menu options.
1. Click and drag the CIR (bands 4,3,2) qb_boulder_msi to the top of the Layer Manager just
below Overview. It should be visible as the top layer.

2. Click the check box for the top layer to deselect it. This hides the image from view. Click the
check box again to display that layer again.
3. Right-click on one of the file names in the Layer Manager, and note the various options, including
Display in Portal, change Order, and Send to ArcMap (you will not see Send to ArcMap if you are
running in 64-bit mode). Select Remove.
4. From the ENVI menu select Views Create New View. The display is divided into two with one
of the Views being empty. The new View is also listed in the Layer Manager.
5. Click the Data Manager icon to open it. Then right-click on one of the band names and select Load
Grayscale. The band will be loaded into the empty View.
6. Experiment with other views by selecting Two Horizontal Views, 2x2 Views, etc.
7. Return to a 2x2 View. There will be four Views listed in the Layer Manager. Right click on the
View at the bottom of the list and select Remove View. You will now have three Views with one of
them extending across the bottom of the display. Use the Data Manager to place an image in any
View that is empty. To select a View for updating, either click on it in the display or click on its
listing in the Layer Manager.
8. Select Views One View and close the Data Manager.

Exploring the ENVI Interface


The ENVI interface includes a menu bar, toolbars, category bars, and a status bar. Much of the ENVI
interface is customizable and provides options to make use of multiple monitors.

12

Exploring ENVI

Exploring the ENVI Interface

Mastering the Basics

Exercise #4: Working with ENVIs Buttons and Sliders


1. Detach the Layer Manager panel by clicking the Detach button
to the right of the Layer
Manager category bar (see image above). Note that the Toolbox also has a detach button.
2. Reattach the Layer Manager panel by clicking the X on the top right of the Layer Manager window.
3. Close the entire Layer Manager panel by clicking on the collapse bar to the right of the categories
(see image above). This allows you to view a larger Image window. Now, open the Layer Manager
panel by clicking again on the same bar (to the left of the Image window).
4. Collapse the Toolbox panel by clicking the arrow or collapse bar to the left of the Toolbox (see
image above). Expand the Toolbox panel by clicking again on the same arrow or collapse bar.
5. Click the Cursor Value button . Then as you move your cursor around the display, you will see
the following information:
Geo: latitude/longitude coordinates are displayed if the image is georeferenced
Map: coordinates are displayed if the image is georeferenced
Proj: projection name is displayed if the image is georeferenced
File name
File: The cursors (sample, line) image coordinates (where the upper-left pixel in the image is
the origin of the coordinate system)
Data: The data values are the actual values of the pixel in the image file. For RGB composites,
three values are displayed. For classification images, the class value and class name are

Exploring ENVI

13

Mastering the Basics

Exploring the ENVI Interface

displayed.
6. Close the Cursor Value dialog. Then click the Crosshairs button
. The Cursor Value dialog will
appear again along with display Crosshairs. The Cursor Value dialog initially shows the
coordinates for the Crosshair. As you move your cursor around the image, the coordinates update to
the cursor position.
7. Click somewhere in the display. The crosshairs will move to you and the Cursor Value dialog
displays those coordinates. Move the cursor away from the crosshairs and the Cursor Value dialog
will update. Now click on the arrow keys on your keyboard. The crosshairs will follow and the
Cursor Value dialog will again display the coordinates of the crosshairs. Close the Cursor Value
dialog and click the Crosshairs icon again to toggle it off.
8. The next button to the right is the Undo button
display. The next button
9. Click the Pan button

. Click on this to undo the last change in the

redoes the change.


then click and drag your cursor in the Image window to pan in the direction

of the mouse. When in Select mode

you can also use the middle mouse button to perform a pan.

10. Click the Fly button


then click in the display and hold to continuously drift in the direction of
the cursor. Positioning the mouse further from the center of the display causes the drift to increase
in speed.
11. The next four button icons are grayed-out. These are used for vector editing and are available when
vector layers are displayed
12. The next several buttons are used for annotation.
them as you have time.

Experiment with

13. Click the Rotate button


then click and drag the cursor in a clockwise or counter-clockwise
direction to rotate the image. The degrees drop-down list near the middle of the upper toolbar
interactively reports the current degree of rotation.
14. Click the Select button

to exit the Rotate tool.

15. Click the degrees drop-down list on the toolbar and select 0. Note that
you can also use the North Up button
instead of the 0 rotation to get
the same orientation. The grayed-out Top Up button
is used to orient
the image when it contains Rational Polynomial Coefficient (RPC)
information.
16. Click the Zoom button
and then click and drag your cursor to draw a box around an area near
the center of the image. This will zoom in to that area.
17. Click on the Fixed Zoom In and Fixed Zoom Out buttons. The current zoom factor and pixel scale
are shown in the drop-down menu to the right.
Click on the arrowhead for this
menu and note the options for zoom factor (pixel scale). At the bottom of this list click on Use Map
Scale. Now select some different map scales from the pull-down menu. Access the drop-down
menu again and select Use Pixel Scale. This will return to the default behavior.
Note: Unless the contrast stretch tool is being accessed, the scroll bar on your mouse will also zoom in
and out. You may have to click in the image display first to activate it.

14

Exploring ENVI

Exploring the ENVI Interface

Mastering the Basics

18. Click on the Zoom To Full Extent button


the display.

. This is a useful button to view your entire image in

19. In the Go To window, type in 660.5,390 and hit the ENTER key. This should center the image on a
track near a large reservoir. If the Crosshairs are turned on, they will be placed on the location you
specify. If you type in x, y locations and both values are integers or are outside the range used for
Lat/Long, ENVI assumes they are pixel coordinates. If x and y values are greater than 30,000,
append a "p" to one of the values to indicate it is a pixel coordinate, not a map coordinate. If the
image is a subset, offsets are taken into account. Data coordinates are specified by appending an
asterisk(*) after one of the coordinates.
20. Type 39 59 51N,105 12 28.5W in the Go To window. The display will be centered on a small beach
jutting into the reservoir. Map coordinates (e.g., Easting and Northing in a UTM projection) can
also be used with the Go To tool. Also, MGRS coordinates can be typed as an alphanumeric string.
MGRS Northing and Easting values can have up to five digits of precision. Note that you can click
on the arrowhead to access a pull-down list of previously used coordinates.
21. The next row of tools in the ENVI menu includes various sliders for Brightness, Contrast,
Sharpen, and Transparency. Experiment with these. They can be manipulated in the following
ways:
Click on the slider bar to the right or left of the indicator, or click the slider then use the
Page Up or Page Down keys to move the slider up or down incrementally by ten percent.
Click on the icons at each end of the slider bar, or click the slider then use the arrow keys on
the keyboard to move the slider incrementally by one unit.
Click the slider then use the Home key on the keyboard to move the slider to 100 and the
End key to move the slider to 0.
22. Click the Reset button

on each slider to return them to their default values.

Exercise #5: Contrast Stretching and Other Tools


1. Experiment with different contrast stretches by selecting options from the drop-down list
. Once this tool is selected, you can use the mouse scroll button to access different
stretches. If you choose Custom stretch, close the histogram window that appears; we will discuss
this stretch below. The Stretch on Full Extent
and Stretch on View Extent icons
can be
used to specify what part of the image is used to determine histogram statistics for the stretches. If
you have multiple layers open, you can click on a specific layer to select it and have the sliders and
contrast stretches operate on that layer. Click the Reset Stretch Type button
to return to the
default.
2. Access the Custom Stretch by either choosing it from the pull-down list or clicking on the
icon.
The pull-down menu of this tool is set to Linear to start. Type in a value of 0.05 in the Linear
(Percent Value) window and hit the ENTER key. The display will update. Try values of 0.5 and 1.

Exploring ENVI

15

Mastering the Basics

Exploring the ENVI Interface

3. Select Gaussian from the Custom Stretch pull-down menu. For Gaussian (Standard Deviation)
type in a value of 0.05. Try values of 0.5 and 1. Click on the Reset Dialog button
to go back to
the default.
4. Click on the Red button to view the histogram for the band displayed as red. You will see BlackPoint and White-Point values showing what data numbers (DN) values are set as upper and lower
limits of the current stretch. If you are in Linear Stretch mode, typing in a Linear (Percent Value)
will cause the Black-Point and White-Point bars to shift. You can also move the Black-Point and
White-Point bars manually. This will automatically update the contrast stretch. If you move the bars
to the end points, the Black-Point and White-Point windows will show the minimum and maximum
values for the data set. Experiment with the other bands that are displayed by clicking on the Green
button, and then the Blue button. When you are finished experimenting click on the Reset Dialog
button
to go back to the default. Close the Custom Stretch tool.
5. Click on the Mensuration tool
. The Cursor Value tool will appear. Next click on the Polyline
annotation button and click in the display to measure something of interest. Distances and headings
between polyline nodes will be displayed in the Cursor Value dialog. If you want to keep the
polyline, right click and choose Accept. If you wish to discard the polyline, right click and choose
Clear. The Arrow annotation can also be used for calculating distance and heading. To clear all
annotations still displayed, right click on the New Annotation layer in the Layer Manager and
select Remove. Choose No to respond to the question about saving the annotation. To clear a single
annotation, right click on it and choose Delete. When finished with annotation click on the Select
button
and close the Cursor Value dialog.
6. The Overview window provides a view of the full extent of the layers loaded into the display. To
turn the Overview window on click in the check box for it in the Layer Manager
. If
you have multiple views in the display, each view has its own Overview. The view box is a smaller,

16

Exploring ENVI

Exploring the ENVI Interface

Mastering the Basics

partially transparent window inside the Overview window that shows the extent of the image visible
in the main display.

7. Increase or decrease the size of the View box by clicking and dragging a corner of that box. This
will zoom in or out on the displayed. The View box adjusts shape to maintain the proper aspect ratio
of the display.
8. Click inside of the View box and drag it to any location within the Overview window to
dynamically update the Image window. Click outside of the View box in the Overview window to
re-center the View box on the spot where you clicked.
9. As you move the View box around it leaves behind a snail trail. This helps by showing you
which part of the scene you have viewed. To clear the snail trail right click Overview in the Layer
Manager and select Clear Snail Trail. If you want to turn the snail trail off, right click on
Overview and de-select Show Snail Trail.
10. Place your cursor in the display and note the information displayed in the Status bar at the bottom of
the ENVI interface. You will see Latitude and Longitude in one block, and map projection and
datum in the next. One block does not show anything currently. Right click in that block and you
will see that NITF classification level is checked. This is not NITF data so nothing is displayed.
You have the option to display anything on the list in any block during the current ENVI session.
You can specify what you want for future ENVI sessions by changing ENVI Preferences. If a scene
is not georeferenced you wont see any map information in the Status bar.

Note: The Status bar always displays information about the base layer in the Layer Manager. For
information on any other layer use the Cursor Value tool.
11. The right-most segment of the Status bar is the Process Manager. It displays the process name and
status for the oldest running process, along with an option to cancel the process by clicking the
Cancel Process button . When all processes finish, this segment becomes blank. As one or more
processes are running, you can click the Process Description button
to display a window that
shows the name and status of each process, and the name of the input images.

Exploring ENVI

17

Mastering the Basics

Working with a Portal, and Blend, Flicker, and Swipe

Working with a Portal, and Blend, Flicker, and Swipe


A Portal is a window inside the display that allows you to view a layer below. A Portal is listed as a separate
layer in the Layer Manager with a distinctive icon.

Exercise #6: Portals


1. Click on the Data Manager icon . Click on Band 3 to load it as Red, click on Band 4 to display
it as green, and click on Band 1 for Blue. Then click Load Data to display the selected bands as a
new layer. Recall you can also use the Band Selection tool at the bottom of the Data Manager to
choose bands for display. Close the Display Manager

2.

You will now see two images listed in the Layer Manager, and the Portal, Blend, Flicker, and
Swipe icons above the display are now selectable. Click the Portal button
on the toolbar. ENVI
creates a Portal to display the lower layer and it is listed in the Layer Manager with the Portal icon
. If you have more than two layers open and you want to see one of the lower layers in a Portal,
right click on that layer in the Layer Manager and choose Display in Portal.

3. Click and drag inside the Portal to move it around the Image window.
4. Click and drag on a corner or side of the portal to resize it.
5. Middle click in the display to access the Pan tool . As you pan around the image notice that the
Portal stays in one spot while the image moves behind it.
6. You can attach (or pin) the Portal to the image so that the Portal moves with the main image. Place
your cursor inside of the Portal near the top to display the Portal toolbar.

18

Exploring ENVI

Chipping and Saving

Mastering the Basics

7. Click the Pin button


. The button changes to Unpin. Middle click and Pan around again. The
Portal stays fixed to the image.
8. Place your cursor at the top inside of the Portal to display the Portal toolbar. Click the Unpin button
on the Portal toolbar.

Exercise #7: Blend, Flicker, and Swipe


Blend, Flicker, and Swipe help you compare two different layers. You can use these tools for comparing
entire images or you can use them inside of a Portal. These tools are enabled only when you have two or
more layers open in the Layer Manager, and when you display at least one layer in the display.
1. Click on the green arrowhead
speed by clicking on the slower
2. Click the Pause button

at the top of the Portal. This starts Flicker. You can change the
or faster

buttons.

on the Portal toolbar to stop Flicker.

3. Right-click inside of the Portal and select Blend. This adjusts the transparency of the top image.
4. Right-click inside of the Portal and select Swipe. Swiping automatically begins between the two
layers.
5. Click the Pause button

on the Portal toolbar to stop the swipe.

6. Close the Portal by either clicking on the x button


at the top of the Portal, right clicking on the
Portal layer in the Layer Manager and choosing Remove, or right clicking in the Portal itself and
choosing Close Portal.
7. Click on the View Flicker button
at the top of the ENVI interface. This opens a new Portal that
covers the entire display. Right click in the display and choose Close View Portal.

Chipping and Saving


In this step, you will take a screen capture of the contents of the Image window, and save the image. The

Exploring ENVI

19

Mastering the Basics

Spectral Profiles

Overview window, any enhancements, zooming, rotating, or Portals that are displayed in the image window
are burned into the output image.

Exercise #8: Saving the Display


1. Click the Chip to File button

on the ENVI toolbar. The Chip to File Parameters dialog appears.

2. From the Output File drop-down list, select JPEG. Next click the File Select button
Select Output Filename dialog appears.

. The

3. Navigate to C:\ENVI_coursefiles\envidata\enviout, and type display_chip as


the output filename. Click Open.
4. Click OK in the Chip to File Parameters dialog. The display chip will be listed in the Layer
Manager and loaded into the display.
5. In the ENVI menu, click on File Chip View To and note the other options for output, which
include Print, ArcMap, and PowerPoint.
6. Right click on the display_chip.jpg file in the Layer Manager and select Remove.

Spectral Profiles
In this step, you will open a spectral plot window and roam around the display. More will be done with this
tool later.

Exercise #9: Opening a Spectral Profile Plot


1. From the ENVI menu bar, select Display Spectral Profile. The Spectral Profile plot window
appears. Click inside the display and drag your cursor around. The plot in the display updates to
show the spectral profile for the pixel under your cursor.
2. Move your cursor into the plot. As you get near a specific band, the X and Y values at that
wavelength will be displayed in the lower right corner of the plot window.

20

Exploring ENVI

ENVI Help

Mastering the Basics

3. Collect spectra in the plot by SHIFT clicking. Collect spectra from different land cover types to see
how they compare.
4. Click on the arrowhead on the right side of plot window to show the plot key panel. All the
spectra will be listed along with their pixel coordinates.
5. Right click in the plot and select Remove All.
6. Close the Spectral Profile plot. You will use the Spectral Profile tool again in a later chapter.
7. Right click on the View item in the Layer Manager and select remove All Layers.

ENVI Help
Extensive ENVI documentation is accessible from within ENVI, and printable documentation and tutorials
are available on the ENVI web site (http://www.exelisvis.com/ProductsServices/ENVI.aspx). ENVI Help
includes Contents, Index, Search, and Favorites tabs to help you find topics quickly and easily.

Exercise #10: Using ENVI Help


1. From the ENVI main menu bar, click on the Help Contents.
2. The Contents tab of Help is open by default. On the left side of this page, click the plus (+) sign
next to Explore Imagery to expand this topic. Click on the Display Tools sub-topic. Information
on many of the tools discussed in this chapter is shown in the right panel.
3. An even quicker way to find a topic in the Help is to use the Index tab to conduct a search of the
index. Click the Index tab, then search for information on how to custom-configure ENVI by typing
Preferences in the text window near the top, then hitting the ENTER key. You will set some
preferences in the next section.
4. Click on the Search tab. This also gives you a text window in which to type your search topic. Type
Preferences in the text window near the top, then hit the ENTER key.

Exploring ENVI

21

Mastering the Basics

More on Setting Preferences

5. Under Title you should see Preferences listed with a Rank of 1. Click on the Star button
it to Favorites.

to add

6. Click the Favorites tab. You will see Preferences listed as a Favorite Topic. Clicking on this
shortcut allows you to quickly access this section of ENVI Help.
Note: Many of ENVIs tools, including the Data Manager, have the Help icon
more information on that tool.

you can click for

More on Setting Preferences


Exercise #11: Changing the Output Directory and Other Options
1. From the ENVI main menu bar, select File Preferences. The Preferences dialog appears.
2. Click on Directories. This is the most commonly customized part of ENVI. For this class, all of the
data you will be using are contained here C:\ENVI_coursefiles\envidata. Click on
Default Input Directory then click on the black arrowhead
to browse for this folder. After you
navigate to it and select it, click OK.
3. Make sure that your Output Directory still says ENVI_coursefiles\envidata\enviout.
All of the output files produced during the class will go into this subdirectory.
4. Click on the Display General listing. Note that you can change the Middle Mouse Action in the
display, Mensuration Units, and Geographic Coordinate Format. You can also specify what item
goes into each of the three Status Bar Segments.

22

Exploring ENVI

Spatial and Spectral Subsetting

Mastering the Basics

5. Click on the Annotation listing. Note that you can set up properties for the various types of
annotation.
6. Click the OK button to close the Preferences dialog.

Spatial and Spectral Subsetting


For many applications, it is helpful to think about multispectral data sets as a 3D cube with all of the bands
stacked on top of one another (as in the figure below).

lines

Visualizing image data in this manner makes it easy to see that multispectral images provide information in
two distinct domains: spatial and spectral. The spatial domain of the data represents an area within any one
band (in sample/line space), while the spectral domain of the data represents the response of any one pixel
in all of the bands (in band space).

samples
Many processing algorithms can be categorized as either spatial or spectral, depending on the domain from
which the data are extracted for processing. For example, image registration is a spatial function, while
image classification is a spectral function. When applying routines such as these, it is convenient to define
the part of the image that you would like to work on at the time the processing is being set up. In ENVI, you
can easily do this through the use of the standard file input selection dialog.

Exploring ENVI

23

Mastering the Basics

Spatial and Spectral Subsetting

Exercise #12: Defining Subsets


1. From the ENVI Toolbox, expand Raster Management and double click on Resize Data. The
Resize Data Input File dialog appears.
2. To open up the data set you will subset, click Open New File. Then browse to
C:\ENVI_coursefiles\envidata\WorldView2 and double click on
New_Zealand_WV2.dat. In the Resize Data Input File dialog, notice that:

The right side of the dialog window lists a summary of the image characteristics.
If your processing function allows for image subsetting, then the Spatial Subset and/or
Spectral Subset buttons appear at the bottom of the dialog.

3. Click the Spatial Subset button. The Select Spatial Subset dialog appears, allowing you to define
spatial subsets in several different ways:
The sample and line ranges can be explicitly typed using the fields provided.
Clicking the Subset Using Image button allows you to drag and re-size a box on a thumbnail
picture of the image to define a subset.
If the image is georeferenced, clicking the Subset Using Map button allows the subset to be
defined by entering map coordinates.
You can subset your image using the area of another image, or you can subset your image based
on the area encompassing selected regions of interest (ROIs) or ENVI Vector Files (EVFs).

24

The Open drop-down button allows you to open an ROI File, or EVF File. The Previous button
automatically applies the last spatial subset used to the current selection (this can save time
when the same subsets are being applied to multiple images).

Exploring ENVI

Spatial and Spectral Subsetting

Mastering the Basics

4. Click the Subset Using Image button and define an area that captures only the left half of the image,
similar to the image shown at right (the exact subset is not important for this exercise).
To resize the box, click on the corner of the box and drag.
To move the box, click inside the box and drag to the new location.
Click with the left or middle mouse button to center the box on the cursor.

Exploring ENVI

25

Mastering the Basics

Closing Files

Click OK. The Select Spatial Subset dialog reappears with the sample and line ranges from your
selection entered into the corresponding fields. You can make additional changes to the subset here
if you want.
5. Click OK. You are back to the Resize Data Input File dialog. Click OK again.
6.

The Resize Data Parameters dialog appears with the output file dimensions. You have the option to
change the pixel size here.

7. Click Choose and browse to the output directory if necessary. Type in an output file name of
NZ_WV2_sub.dat and click Open. Click OK to perform the process.
8. The subset will be displayed on top of the input file. Inspect your subset result by adjusting the
zoom level and panning around.
9. When finished, right click on the View listing in the Layer Manager and select Remove All Layers.

Closing Files
Once a file is opened in ENVI, it always remains open until the session is ended or you manually choose to
close the file. However, because data from the files are only read when needed, having many files opened
does not consume any memory. Nonetheless, sometimes it is useful to remove an opened file from the ENVI
session.

Exercise #13: Close Files


1. Open the Data Manager and click on Close File
button or Close All Files
button. You can
also close files by right clicking on a file in Data Manager and selecting either Close File or Close
All Files.
2. Close the Data Manager.

Skills Check
At this point you should:
Know how to create RGB or Gray Scale displays
Know how to find and use ENVI Help
Understand how to change ENVI Preferences
Know how to spatially subset an image.

Self Test
1. From this point forward, when you write a new file to disk from ENVI, where is it written by
default?
2. What options do you have to define a spatial subset?

26

Exploring ENVI

Chapter 2:

Raster Data
Management

Learning Objectives.................................................................................................................. 28
Prerequisites ............................................................................................................................ 28
Required Tools for Completing This Module ............................................................................. 28
Associated Data ....................................................................................................................... 28
The ENVI Header File .............................................................................................................. 28
Reading Raster Image Data ..................................................................................................... 28
ENVIs Image Format ............................................................................................................... 29
The ENVI Header File .............................................................................................................. 29
Managing Files ......................................................................................................................... 35
Skills Check ............................................................................................................................. 36
Self Test ................................................................................................................................... 36

Exploring ENVI

27

Raster Data Management

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Read various types of raster image data into ENVI
What ENVI standard image file format means
What ENVI header files are and how to edit them
Useful file management techniques

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. You should also know how to
display an image in ENVI.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

FlKeys.tif Quickbird image of Florida. This data set is a high-resolution (2.8 m pixel size)
multispectral image from DigitalGlobes QuickBird satellite. It is a subset of a scene acquired in
2002. It covers an area in the Florida Keys, USA (Cudjoe and Cedar Keys). It has been
geometrically corrected to a UTM projection and distributed in GeoTIFF format. ENVI
automatically reads the information from the GeoTIFF tags embedded in the file and can easily
import the data and map information.
Note: Image courtesy of DigitalGlobe (www.DigitalGlobe.com). The data is to be used for class
exercises only and any other use of the data including resale, distribution or reproduction, or for
purposes other than noted above without the prior written permission of DigitalGlobe is strictly
prohibited.
bldr_tm.dat - Landsat TM scene over Boulder, CO, which does not currently have an ENVI
header.

Reading Raster Image Data


There are hundreds of different formats for storing image data, which can often make working with remote
sensing data difficult. ENVI uses a very flexible method for importing raster data that allows virtually any
type of image data to be imported. ENVI also includes custom readers for common remote sensing formats,
as well as for generic and special image formats produced by other image processing software. The custom
readers are found under the File Open As option in the ENVI menu bar.
Image files open in ENVI almost instantaneously regardless of size. When roaming around the image the
display refreshes rapidly. The reason for this is that ENVI uses pyramid files which are copies of the data
file at various reduced resolutions. ENVI only builds pyramids for a data file the first time you open it.
When you open the data file thereafter, it displays more quickly because it accesses the previously built
pyramid file. For some compressed data formats, ENVI does not need to create a pyramid file.
Pyramids are used to speed image display by reducing the resampling required when displaying large
portions of an image at low resolution. The Process Manager in the Status bar shows the progress of
building pyramids when you first open a data file.

28

Exploring ENVI

ENVIs Image Format

Raster Data Management

By default, pyramid files are created in the directory containing the original data file. If this directory is
unavailable (due to write permission, for example), ENVI attempts to write the pyramid file in directory set
in the Alternate Header Directory preference. If this is not available, ENVI uses the IDL temporary
directory.

ENVIs Image Format


ENVI image files (those generated by ENVI) are stored in the simplest possible generalized raster format,
which consists of a binary stream of bytes without embedded non-image data or structural elements of any
type. This format is typically referred to as a flat-binary file and is commonly described as a lack of
format because of its simplicity.
Because the image file does not contain embedded non-image data, each file has an accompanying ASCII
file called the ENVI header file which contains all of the information needed to read the data in as an image.

Exercise #1: Reading Image Formats and Header File Input


1. From the ENVI menu bar, select File Open As and examine the list of supported formats.
ENVIs numerous custom readers make it possible to read very complicated formats, such as the
10-bit compressed AVHRR Level 1B, RADARSAT, or TOPSAR data. Other file types in the list
are flat binary but contain embedded binary data that describe the image; or they have special
format header files which specify the image dimensions, wavelengths, or map information. In
addition, ENVI can read formats from other vendors, such as Multi-Resolution Seamless Image
Database (MrSID) compressed format single-band or three-band files, or Enhanced Compressed
Wavelet (ECW) images.
When using one of the custom readers for file import, ENVI automatically extracts all of the
information contained in the input file and enter its image bands into the Available Bands List. In
some cases, the image format being read includes not only the information required for reading the
data itself but also ancillary information such as georeferencing data, wavelengths, or band names.
You are not required to know any details about data files to import them into ENVI.
With each new ENVI release, and as more instruments are developed, the list of supported formats
with special custom readers in ENVI is expanded.
2. From the ENVI Toolbox, expand Raster Management and double click on Edit ENVI Header.
3. In the Edit Header Input File dialog, click on the Open tab and select New File. Then navigate to
the envidata\QuickBird directory, select FlKeys.tif, and click Open. Note the
dimensions, interleave, data type, and file size listed in the File Information panel. Click OK. The
Header Info dialog appears.

The ENVI Header File


Image files opened in ENVI have an ENVI header file associated with them. This is true even for images
that are stored in memory only or that are imported into ENVI in their native format (without being
converted into ENVI image format). The ENVI header file is a small ASCII text file that contains the basic
information that ENVI must know in order to read the image data (such as the number of samples, lines, and
bands), as well as any other ancillary information available (such as band names and wavelengths). When
importing a file using one of ENVIs custom readers, ENVI extracts the necessary information from the files
and then automatically generates an ENVI header file. When reading an image without a custom reader in
ENVI (a generic raster image), ENVI prompts you to enter the basic required image information then
generates a header file. Once a file has an ENVI header, ENVI reads it without any input from you.

Exploring ENVI

29

Raster Data Management

The ENVI Header File

Header files are always named with the same root name as the image data file but with a.hdr extension.
Thus, in most cases, after a file has been read by ENVI, you end up with a pair of files for each image - the
image file and the ENVI header file.
When reading an image in its native format (for example, a TIFF file), ENVI only creates a header file in
memory. However, if you add any more information to the file that cannot be stored in the images native
format (for example, adding band names to a TIFF image), ENVI creates a.hdr header file.

Required Information
The Header Info dialog provides access to the editable fields in the ENVI header file. The fields that are
required are shown in the main Header Info view. The required image descriptor fields are:
Number of samples per band
Number of lines per band
Number of bands in the entire file
Offset (in bytes) of embedded header data before the image data begins
Data type (i.e., number of bytes per image pixel)
Byte order (related to the type of operating system that wrote the data)
File type (a list of ENVI categories; ordinary raster images are ENVI standard)
Interleave (the storage format for multi-band images)
The two remaining fields, xstart and ystart, are not technically required. These two values define the image
coordinates to use for the first pixel in the image (i.e., the upper-left pixel). By default, the upper-left pixel is
assigned a value of (1,1). Changing these values introduces an offset in the image coordinates reported by
tools like the Cursor Value. However, it does not in any way change or subset the actual image data.

Optional Information
The header file can also contain a wealth of ancillary information about the image, ranging from a simple
text description to detailed map projection information, band wavelengths, associated DEM file, and

30

Exploring ENVI

The ENVI Header File

Raster Data Management

instructions for how to display the image. All of the optional fields are accessed using the Edit Attributes
drop-down button.
4. In the Header File dialog, click the Edit Attributes drop-down button and examine the optional
fields available. Some fields are only appropriate for special file types so they are unavailable
(grayed out).
5. Select Wavelengths. The Edit Wavelength values dialog appears. If the wavelengths for the bands
do not appear, then first click on Band 1, then in the text edit window that appears type in 0.485 and
hit the ENTER key.
6. Band 2 will be selected now. For Band 2 type in a value of 0.560 and hit the ENTER key.
7. For Band 3 use a wavelength value of 0.660 and for Band 4, a value of 0.830.
8. Click on the drop-down menu for Wavelength/FWHM Units and choose Micrometers. Then click
OK.
9. In the Header File dialog, click the Edit Attributes drop-down button and select the Map Info
option. The Edit Map Information dialog appears.
The Map Information header field defines georeferencing information for the image by specifying
the projection into which the image is geometrically corrected, as well as a reference pixel for which
a map coordinate and pixel size are defined.
The Map Information for the Florida QuickBird image was filled out automatically by ENVIs
custom QuickBird reader when the image was opened.
10. Click Cancel to return to the main Header Info dialog, then click OK again to exit the Header Info
dialog. The Data Manager and the Layer Manager will now show wavelength values. You may see
the display update as well with this new header information.
11. In the Layer Manager, right click on the View listing and select Remove All Layers.

About Header Values


Data Types
ENVI currently supports nine different IEEE data types, each defined in the table below. When defining the
ENVI header for a new file that contains integer data, it is critical that you know the number of bytes per
image pixel and whether or not the integer is signed (can have negative values) or unsigned (only positive
values)
Table 1: ENVI Data Types

ENVI Data Type


Byte
Integer (signed)
Unsigned integer
Long integer (signed)
Unsigned long integer
Floating point
Double precision
Complex (floating point)
Complex (double precision)

Bytes-per-pixel
1
2
2
4
4
4
8
8
16

Range of values
0 to 255
-32768 to +32767
0 to 65535
Approx +/- 2 billion
Approx 0 to 4 billion
+/- 10
+/- 10
Real and imaginary are floats
Real and imaginary are doubles

Interleave
Interleave refers to the storage order for data in a multi-band image. There are three different types of

Exploring ENVI

31

Raster Data Management

The ENVI Header File

interleaves: band sequential (BSQ); band interleaved by line (BIL); and band interleaved by pixel (BIP).
Even though we often visualize a multi-band image as a cube, in the computers memory the entire image is
really just a continuous stream of bytes. The interleave describes how this stream of bytes for the multi-band
image are ordered in memory.
For BSQ images, the stream of bytes runs through each full image band sequentially (from the upper-left
pixel to the lower-right pixel), then begins again at the first pixel of the next band. Thus, the data for any
given image band are next to each other in memory, allowing very fast access for extracting spatial data or
displaying images. BIP images are stored in the opposite order, where each pixel spectrum is next to each
other in memory (i.e., each bands value for pixel 1, then each bands value for pixel 2, etc.). This
arrangement allows very fast access to spectral data but relatively slow access to spatial data. BIL images
use a storage order that is a compromise between BSQ and BIP. In BIL images, the same line from each
band is stored next to each other in memory (i.e., line 1 of all bands, then line 2 for all bands, etc.). See the
figure on the next page for an illustration of the three interleaves.

Byte Order
DEC workstations and PCs read and write binary data in a slightly different manner than older Macintosh
and UNIX operating systems. Because ENVI can run on all of these platforms, it is important to know
which type of operating system wrote the image data that is being imported. The two byte orders are called
Host (Intel), which reads the least significant byte first (for the DEC workstations and PCs) and Network
(IEEE), which reads the most significant byte first (UNIX and older Macintosh). If the file was created in
ENVI, then this header field is automatically set so that the file can be read into ENVI on any of its
supported platforms.

32

Exploring ENVI

The ENVI Header File

Raster Data Management

Exercise #2: Defining an ENVI Header


If the image does not have an ENVI header file that is, if it has never been opened in ENVI before a
header file can be generated. After defining the required header information, ENVI writes the header file to
disk and uses it whenever the file is read into ENVI in the future. Because the data for this exercise have
been subset into a small scene, the original Landsat header information no longer applies and the custom
readers cannot be used.
1. From the ENVI Toolbox, expand Raster Management and double click on Edit ENVI Header.
2. In the Edit Header Input File dialog, click on the Open tab and select New File. Then navigate to
the envidata\boulder directory, select the bldr_tm.dat file, and click Open. After the file
is opened, ENVI searches for a file called bldr_tm.hdr, the name the associated ENVI header
file would have if it exists. If an ENVI header does not currently exist, an empty Header Info dialog
appears.
3. Given the following information about this image file, if the needed parameters are missing, type
them in.
Note: Because ENVI is a cross-platform application, the Windows TAB key to move between fields
is disabled. However, it is best to get into the habit of hitting the ENTER key when filling in ENVI
dialogs. In some cases, hitting the ENTER key will move you from item to item as the tab does in
Windows. Also, some ENVI dialogs wont recognize that you typed values in unless you hit the
ENTER key.

Exploring ENVI

33

Raster Data Management

The ENVI Header File

Samples 702
Lines 863
Bands 6
Offset 0 bytes
File Type ENVI Standard
Byte Order Host (Intel)
Data Type Floating Point (i.e., 4-bytes per pixel)
Interleave BIP
Band Names = Band 1, Band 2, Band 3, Band 4, Band 5, Band 7
4. To enter the band names, click the Edit Attributes drop-down button, and select Band Names.
Make sure there is a Band 6 but no Band 7 in the list. If necessary you would click on Band 6 and
change that to read Band 7, and hit the ENTER key. Click OK.

5. Unlike the Florida QuickBird image, the Boulder TM image is not georeferenced. The image has
been geometrically corrected; however, the Map Info has not been entered into its ENVI header file.
Click the Edit Attributes drop-down button, and select Map Info. The Edit Map Information
dialog appears.
6. Use the pixel with an image coordinate of (526,645) for the reference pixel. In the Image X field,
type 526. In the Image Y field, type 645.
7. The Boulder image is in a UTM projection, Zone 13 N. Click the Change Proj button. Select UTM
and type 13 in the Zone field. Keep the datum at its default setting of North America 1927. Click
OK to set the new projection.
8. Enter the following UTM map coordinate values for the reference pixels: in the E (easting) field,
type 480168.67; in the N (northing) field, type 4427572.69.
9. The Landsat TM image pixel size is 30 m. In both the X Pixel Size and Y Pixel Size fields, type
30.0.
10. The Map Information dialog is now complete. Click OK to return to the Header Info dialog.

34

Exploring ENVI

Managing Files

Raster Data Management

11. Next, you will define the wavelengths for the six bands. Click the Edit Attributes drop-down
button, and select Wavelengths. The Edit Wavelength values dialog appears.
12. ENVI allows wavelength values to be read directly from an ASCII file (this is particularly
convenient for hyperspectral data sets where you may have hundreds of bands). Click the Import
ASCII button, navigate to the envidata/boulder directory, select the twave6.asc file, and
click Open. This file contains both the wavelengths for the six TM bands and also the full-widthhalf-maximum values (FWHM) for these bands.
13. The Input ASCII File dialog appears. In the Wavelength Column field, type 1. In the FWHM
Column field, type 2, then click OK to return to the Edit Wavelength Values dialog.
If the ASCII file contained only wavelengths, you could leave the FWHM Column empty; it is
convenient to import it with the wavelengths if it is available.
14. Click OK in the Edit Wavelength Values dialog then click OK in the Header Info dialog to accept
the ENVI header file information. The image will now be displayed.
15. Close the Edit Header Input File dialog.
16. Ensure that the Boulder TM image listing in the Layer Manager now specifies band wavelengths.

Managing Files
There is no limit to the number of files that can be opened simultaneously in ENVI; therefore, you may find
yourself with so many bands available that you cant find the one you are looking for. This problem can be
compounded when working with hyperspectral images, which can add hundreds of entries into the Data
Manager.

Exploring ENVI

35

Raster Data Management

Skills Check

Exercise #3: Additional File Management Tools


Folding Images
When several multi-band images have been opened, the Data Manager List can become quite crowded. One
solution for this problem is to temporarily collapse all of the bands in a multi-band file into a single entry in
the list.
1. Open the Data Manager by clicking on its icon just to the right of the Open folder icon. At the top of
the Data Manager are plus (+) and minus (-) icons. To collapse the bands so that only the filename
is listed, click on the Collapse All (-) icon. The individual bands are no longer displayed.
2. To expand all files, click on the Expand All (+) icon.
3. You can collapse or expand individual files by click on the
either the Data Manager or the Layer Manager.

or

icons next to each file listing in

4. Close the Data Manager.


5. Collapse and expand the listings in the Layer Manager by clicking on the Collapse All
Expand All
icons at the top of the Layer Manager.

and

6. When you are finished with this exercise, right-click on bldr_tm.dat in the Layer Manager, and
select Remove.

Skills Check
At this point you should:
Know how to open specific file formats in ENVI
Know how to edit ENVI headers

Self Test
1. What are the items in the header file that ENVI needs to know in order to display an image?
2. How can you collapse and expand file listings in the Data Manager?
3. What information is contained in an ENVI header file?

36

Exploring ENVI

Chapter 3:

Image Display Concepts

Learning Objectives.................................................................................................................. 38
Prerequisites ............................................................................................................................ 38
Required Tools for Completing This Module ............................................................................. 38
Associated Data ....................................................................................................................... 38
Stretching Image Data.............................................................................................................. 38
Color Tables ............................................................................................................................. 42
Raster Color Slices .................................................................................................................. 44
Skills Check ............................................................................................................................. 48
Self Test ................................................................................................................................... 48

Exploring ENVI

37

Image Display Concepts

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Control the contrast stretch of an image
How to apply color to gray scale images
The difference between color tables and raster value ranges

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

SEcoast.dat AVHRR data from the NOAA-16 satellite over the southeastern United States.
The data set contains four bands of AVHRR data with a pixel size of 1100 m. The image was
obtained in September, 2001
Grnland - AVHRR data from Greenland.

Stretching Image Data


Why are image data contrast stretched when making a display?
The pixels in a data file that make up an image can have any value - negative, positive, integer, or floating
point. When the image data are projected on screen, they are displayed as brightness values for each screen
pixel. A data pixel with a larger value is brighter than one with a smaller value. However, unlike the image
data, screen pixels can only have 256 unique brightness values, varying as integers between 0 and 255
(where 0 is black and 255 is white). Clearly this limitation prevents the most of the data from being
displayed with brightness exactly equal to their real value. For example, how do you display a negative data
value or floating point data ranging from 0 to 1?
Stretching the image data refers to a method by which the data pixels are rescaled from their original values
into a range that the monitor can display namely, into integer values between 0 and 255. For example, if
the image data were floating point values that ranged from -1.0 to 1.0, the image might be stretched such
that data values of -1.0 are assigned a brightness of 0 and data with values of 1.0 are assigned a brightness of
255. All of the intermediate data values would be assigned new stretched values based on a simple model, or
stretch type. Commonly, a linear stretch type is used so that the stretched data values maintain the same
relationship to each other as the original data (i.e., the relative distance between two stretched values is the
same as the relative distance between the two original data values). Other stretch types, such as gaussian,
equalization, or square root functions use different models to assign the intermediate values.

Exercise #1: Comparing Data and Stretched Values


1. From the ENVI menu bar, click on the Open folder, navigate to the envidata\avhrr directory
and open the image SEcoast.dat. The first band of this data set has been calibrated into sea
surface temperatures (SST) in degrees Celsius and is floating point data.
2. Open up the Data Manager, right click on the SST image band, and select Load Grayscale. A gray
scale image of the SST band is displayed.

38

Exploring ENVI

Stretching Image Data

Image Display Concepts

3. Click on the Cursor Value icon to bring up that tool. Click on the Zoom to Full Extent icon then
roam around in the image and note the data values for the SST image.
What is meant by contrast stretch?
The stretch used to rescale image data into brightness values can make a drastic difference in the way that
the image appears. You can adjust the parameters of the stretch in order to maximize the information
content of the display for the features in which you are most interested. This process is referred to as
contrast stretching because it changes contrast in the image. Contrast refers to the relative differences in the
brightness of the data values (i.e., increasing contrast means that the dark pixels are darker, and the bright
pixels are brighter, so the brightness differences are increased).
For example, consider an image whose data numbers (DN) are integers that range between 35 and 85 (51
different data values). If this image was stretched with a simple one-to-one model where a data value of 0
is assigned 0 brightness, and a data value of 255 is assigned 255 brightness, then the image display is quite
dim (since the brightest pixel is only a brightness of 85). This stretch produces a low-contrast image because
a difference in data value of one unit is represented by a difference in brightness of one unit. Furthermore,
much of the range of available screen brightness is not being used because there are only 51 different values
in the image data (there are no pixels with a brightness between 85 and 255, so these brightness values are
unused).
The image contrast could be maximized by assigning a brightness of 0 to the minimum data value of 35, a
brightness of 255 to the maximum data value of 85, and linearly stretching the remaining 49 data values
through the rest of the available brightness range. This increases the contrast because adjacent data values
now differ by several units of brightness rather than just 1, making it easier to visually distinguish slight
differences in the data values.
Through careful adjustment of the image stretch, it is possible to highlight certain features in an image.
ENVI provides several sophisticated tools for this purpose.
4. From the contrast stretch pull down menu, select various contrast stretches from No stretch to
Optimized Linear. Once you select a contrast stretch you can use the roller button on your mouse
to move from stretch to stretch. However, if you choose Custom, to get back, you will have to close
the Custom Stretch dialog and manually select another contrast stretch.
Listed below are the predefined contrast stretches that are available.
No stretch sets a data value of 0 to a screen value of 0 and a data value of 255 to a screen value
of 255. Each data value corresponds to the same screen value.
The Linear stretch sets the data minimum and maximum to screen values of 0 and 255 and
stretches all other data values linearly between 0 and 255.
The Linear 1% stretch sets the lowest and highest 1% of data values to screen values of 0 and
255 respectively, and stretches all other data values linearly.
The Linear 2% stretch sets the lowest and highest 2% of data values to screen values of 0 and
255 respectively, and stretches all other data values linearly.
The Linear 5% stretch sets the lowest and highest 5% of data values to screen values of 0 and
255 respectively, and stretches all other data values linearly.
The Equalization stretch scales the data to equalize the number of DNs in each display
histogram bin.
The Gaussian stretch sets the data mean value to a screen value of 127, the data value three
standard deviations below the mean value to a screen value of 0, and the data value three
standard deviations above the mean value to a screen value of 255. Intermediate data values are
assigned screen values using a Gaussian curve.

Exploring ENVI

39

Image Display Concepts

Stretching Image Data

The Square Root stretch takes the square root of the input histogram and applies a linear stretch.
The Logarithmic stretch is a non-linear technique where the low-range brightness is enhanced.
This stretch is useful for enhancing darker features.
The Optimized Linear stretch is also known as a dynamic range adjustment. By default, 16-bit,
unsigned integer data use the optimized linear stretch for display as it has a dynamic range set
that is optimal for integer data. This stretch provides the maximum amount of information from
the midtones and from the shadow and highlight regions.

5. With the full extent of the scene visible, which contrast stretch appears best for the land? Referring
to the Cursor Value dialog, what data values do you see for land?
6. Which contrast stretch appears best for the land? Refer to the Cursor Value dialog and note what
data values are for the ocean? Note that near the bottom of the scene there are several pixels with
negative values as well as NaN.
7. Click the Fixed Zoom In icon once then middle click and drag to pan so that the area of negative
values is no longer in the display. Then click on the Stretch On View Extent icon. The contrast
stretch will update because the image statistics changed.
8. With Stretch On View Extent still active zoom and pan so that you fill the display with the land.
Now experiment with different contrast stretches. Which stretch works best now?
9. Pan over so that you fill the display with the ocean. Experiment with contrast stretches for the
ocean.
10. Click on Stretch on Full Extent and then click on Zoom To Full Extent to work on and view the
entire scene.
11. ENVI has a tool you can use to save a stretched image. In the ENVI Toolbox, expand Raster
Management then double click on Stretch Data. Select SEcoast.dat, then click on Spectral
Subset and select only the SST band. Click OK twice.
12. In the Data Stretching dialog, click on Stats Subset. In the Select Statistics Subset dialog, note that
you can use histograms from part of the image, an ROI, or EVF to define your stretch. Click on
Image.
13. In the Subset by Image window, click and drag to resize the red box and position it to cover an area
over the ocean. Then click OK twice to get back to the Data Stretching dialog. For Stretch Type
select Equalize.
14. For Output Data Range, type 0 for Min and 255 for Max. For Output Result, choose Memory.
Then click OK. You may get a warning regarding the amount of memory required. Choose
Memory again and click OK.
15. After the stretch is computed, the result will be displayed. After inspecting the result, right click on
the Memory item and select Remove. Close the Cursor Value dialog.

Exercise #2: Custom Stretch Tool


In this exercise you will use the Custom Stretch tool to manually manipulate contrast.
1. From the contrast stretch pull-down menu, select Custom.
2. The Custom Stretch dialog appears with a histogram of the data set. From the drop-down menu in
this dialog experiment with the different stretches (Linear, Equalization, Gaussian, Square Root,
and Logarithmic).
3. Choose Linear and then type in a value of 3 for Linear (Percent Value). Hit the ENTER key after

40

Exploring ENVI

Stretching Image Data

Image Display Concepts

typing so the ENVI reads your input.


4. Type in a value of 0.5 and hit the ENTER key.
5. Next choose Gaussian. For this stretch you can specify a standard deviation. Type in a value of 1
for Gaussian (Standard Deviation) and hit ENTER.
6. Next you will use the Custom stretch tool on a color image. Right click on the View listing in the
Layer Manager and select Remove All Layers.
7. Click on the Open folder and from the avhhr directory choose grnland and click Open.
8. A grayscale image is displayed because this data set does not have wavelengths associated with it.
Open up the Data Manager and click on Bands 5, 3, and 1, then click Load Data.
9. Click the Zoom To Full Extent icon. Select Custom from the contrast stretch pull-down menu.
The Custom Stretch histogram appears with histograms for the three bands displayed as red, green,
and blue. Note that the blue band has significantly lower values than the other two.

There are four buttons on the right side of the dialog. You can stretch the data loaded to the red,
green, or blue plane of the image display once you select the appropriate button. The Input
Histogram is shown in the color corresponding to the color plane that is currently selected. For
example, if you select the green button, then the Input Histogram is green, and the dialog controls
the green color plane of the display. Thus you can stretch each color plane of the display separately.
10. You will now adjust the contrast so as to focus on the glacier in the middle part of the image. First
click on the Cursor Value icon to bring up that tool. Then move your cursor around over the glacier
and note what values you see for the displayed bands. You should get approximately2600 to 2700
for the band displayed as red, about 2650 to 2750 for the band displayed as green and roughly 650
to 740 for the blue band.
11. Click on the red button on the right side of the dialog. The plot will update to show just the

Exploring ENVI

41

Image Display Concepts

Color Tables

histogram for the band displayed as red. The Black Point and White Point items show values that
reflect the last stretch that was applied. Make sure that Linear is the stretch type being used. Type in
a value 2600 for the Black Point and a value of 2700 for the White Point. Note that these values
delineate a particular peak in the histogram. This peak likely represents the glacier.

12. Click on the green button on the right side of the dialog. The plot will update to show the histogram
for the band displayed as green. Move the Black Point threshold to about 2650 and the White Point
threshold to near 2750.
13. Click on the blue button on the right side of the dialog. Move the Black Point threshold to about 650
and the White Point threshold to near 740. The resulting stretch should show variation in the glacier
area.
14. Close the Custom Stretch and Cursor Value dialogs. Right click on the View item in the Layer
Manager and select Remove All Layers.

The Default Stretch Hierarchy


You can specify a specific stretch for a file that will override ENVIs default for that particular data type. In
an images ENVI header file, there is a Default Stretch listing under Edit Attributes that can specify a stretch
type and initial parameters to use for the images default stretch.

Color Tables
There are several ways to create color displays of image data. For example, you can create RGB color
composites, where the color of each pixel is defined by its relative brightness in three different images.
However, you can also use colors to accentuate features in a single band gray scale image. ENVIs color
tables are a special kind of lookup table that associates a screen brightness value with an RGB triplet (a
color).

Exercise #3: Applying Color Tables


1. Open the Data Manager, right click on the SST image band of SEcoast.dat, and select Load
Grayscale. Adjust the zoom level so you see all of the image.

42

Exploring ENVI

Color Tables

Image Display Concepts

2. Right click on the file in the Layer Manager and select Change Color Table Rainbow. The
image is colored using this color table.
3. Experiment with different contrast stretches. As you can see, the color table responds to the contrast
stretch. Remember, the color table associates a screen brightness (i.e., a stretched data value) with a
fixed RGB triplet. Whenever the stretched values change, the colors on the display also change.
Adding color to a gray scale image brings a new dimension to its contrast and can help distinguish
features that are otherwise hard to see because they have similar brightness values.
4. Right click on the SEcoast.dat file in the Layer Manager and select Change Color Table
More. In the Change Color Table dialog click on Load IDL Color Table. A list of all available
color tables is displayed. Experiment by selecting different color tables.

5. At the top of the window, the horizontal color ramp displays the currently selected color table, from
minimum brightness at the left to maximum brightness at the right. Click on Reverse to flip the
color table so the minimum brightness color now corresponds to the maximum brightness value.
6. Click on Load IDL Color Table and select Rainbow 18. This color table shows a lot of variation
in the ocean. If you wanted to accept this color table you would click OK. However, you will
continue to work with this tool in the next several steps.
7. The Change Color Table dialog also allows you to define your own color table using RGB (redgreen-blue), HLS (hue-lightness-saturation), HSV (hue-saturation-value), or CMY (cyan, magenta,
yellow) color spaces. HLS is selected by default so you will use this color space. The next step is to
select a color space element. Check the box for H (Hue). The other two elements (Lightness and
Saturation) now represent the horizontal and vertical axes of the right-hand panel.
8. In the right-hand panel move the left-hand node up and into the dark red area. Placing the nodes in
the upper part of the window produces a more saturated color. Positioning nodes near the bottom of
the window produces less saturated color.

Exploring ENVI

43

Image Display Concepts

Raster Color Slices

9. Check the box for L (Lightness). The horizontal axis now represents Hue and the vertical axis
represents Saturation. Adjust the nodes in the right-hand panel by placing them in various hues. For
example you could place the left-hand node in red and the right-hand node in blue.

10. Check the box for S (Saturation). The horizontal axis now represents Hue and the vertical axis
represents Lightness. Dont change the nodes here but check the box for L again. If you are
satisfied with this result, click OK in the Change Color Table dialog.
11. If you did not click OK you can continue to adjust color spaces. When you are finished
experimenting close the tool by either by clicking OK (the last color table applied will stay), or by
clicking Cancel (the color table will revert to whatever it was before you opened the dialog).

Raster Color Slices


In some cases, it may be more useful to color-code an image directly using its data values, instead of its

44

Exploring ENVI

Raster Color Slices

Image Display Concepts

stretched values. This can be accomplished in ENVI using raster value ranges, where specified ranges of
data values are assigned colors. You can even treat this tool as a simple one-band classification of the
image based solely on data ranges.

Exercise #4: Applying Raster Color Slices


1. If you have a color table applied to the SEcoast.dat scene, display the SST image band as a new
grayscale.
2. Right click on the new gray scale image in the Layer Manager and select Raster Color Slices. A
Select Input File dialog appears. Select the SST image band and click OK.
The Edit Raster Color Slices tool appears. It shows a list of colors and the histogram for the SST
band. You can also start this tool by right clicking on the band in the Data Manager, or by double
clicking on it under Classification in the ENVI Toolbox.
By default, equally-spaced ranges are automatically calculated with a different color assigned to
each data range. The icons at the top of the tool allow you to: Change Color Table (the same choices
as you saw in the color table exercise), select New Default Ranges, Add Range, Remove Ranges,
Clear Ranges, Save Ranges to File (.dsr format), or Restore Ranges from File.
3. Select a color either by clicking on its number in the list or by clicking on it in the histogram plot.
Then in the histogram plot, click and drag one of the sides of the color band to change the DN range
for the color. Note that the DN specified at the bottom of the plot updates as you move your cursor.
You can also specify color ranges by typing values in Range Min and Range Max in the color list.
4. Move a color band around by clicking in the middle of it and dragging it left or right. Reset the
color ranges by clicking on the New Default Ranges
icon, leaving the default values in the
Default Raster Color Slices dialog and clicking OK.
5. The Raster Color Slices tool allows you to add color only where you want and leave the original
gray scale image display elsewhere in an image. For example, next you will try to highlight the
ocean by defining ranges which color codes only the data that you think are the ocean pixels. You
could use the Cursor Value tool to determine what values ocean pixels have, but the Cursor Value
tool cannot be accessed while the Raster Value Ranges tool is open. However, you can see that
ocean pixels are bright in the SST image so that means that the peak on the right side of the
histogram represents ocean.
Zoom in to the right hand side of the histogram by clicking and dragging the white triangle at the
lower left corner of the plot to the right near a DN of 20. When you let go the histogram will update
and show only the peak on the right.

Exploring ENVI

45

Image Display Concepts

Raster Color Slices

6. Move your cursor over the histogram now and note DN values between sub-peaks and at breaks in
slope. You will use these values for setting color ranges. Position the warmer colors on the higher
DN values, adjusting their widths to get something like the figure below. You may not see some of
the cooler colors in this portion of the histogram. To make them appear in this range, select a color
from the list then type in Range Min and Range Max values near 20 and 22 respectively. Once a
particular color band is visible, adjust its width and position.

7. Once you are satisfied, double click along the bottom of the histogram to zoom back out.
8. Now select a color band that you wish to delete and click the Remove Ranges icon (clicking on
the double x removes all color slices). Continue deleting colors that you did not use in the histogram
peak that represents the ocean. Your histogram should look something like the figure below.

46

Exploring ENVI

Raster Color Slices

Image Display Concepts

9. When you are satisfied, click OK to close the Edit Raster Color Slices dialog and update the display
with the color ranges.

10. The result will be listed in the Layer Manager. The output is actually a classification result and as
such, you can uncheck color ranges so they wont be displayed. To edit the color ranges, right click

Exploring ENVI

47

Image Display Concepts

Skills Check

on Slices and select Edit Color Slices. Note that you can also generate statistics for the ranges by
right clicking on Ranges.
11. Right click on the View listing in the Layer Manager and select Remove All Layers.

Skills Check
At this point you should:
Know how to work with the contrast stretching tools
Know how to apply color tables
Know how to work with the Raster Color Slices tool

Self Test
1. What are two ways to give color to grayscale images?
2. Are color tables affected by the image contrast stretch?
3. Does the Raster Color Slices tool work with actual data values and so is not affected by contrast
stretches?

48

Exploring ENVI

Chapter 4:

Example Application:
Vegetation Analysis

Learning Objectives.................................................................................................................. 50
Prerequisites ............................................................................................................................ 50
Required Tools for Completing This Module ............................................................................. 50
Associated Data ....................................................................................................................... 50
Preprocessing .......................................................................................................................... 50
Creating Multiband Files ........................................................................................................... 53
Topographic Modeling .............................................................................................................. 56
Image to Image Registration .................................................................................................... 57
Building Masks ......................................................................................................................... 59
Normalized Difference Vegetation Index (NDVI) ...................................................................... 61
Statistics................................................................................................................................... 62
3D SurfaceView ....................................................................................................................... 63
Skills Check ............................................................................................................................. 68
Self Test ................................................................................................................................... 68

Exploring ENVI

49

Example Application: Vegetation Analysis

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Use ENVI to calibrate data
Correct for scattered light
Perform Topographic modeling to derive information from a DEM
Run Image-to-Image Registration
Build a mask to mask out parts of the scene
Apply the NDVI tool
Gather statistics and examine the relationship between topography and the abundance of green
vegetation in the Boulder, CO, area
Use the 3D SurfaceView tool to drape images over a 3D surface generated from elevation data and
fly-through the 3D model

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. Also you should know how to
display an image in ENVI and work with the Layer Manager.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

L5033032_03219850812_MTL Landsat TM of Boulder, Colorado. in Geotiff format with


metadata. Each band is a separate file.
Bldr_dem.dat - A USGS DEM of Boulder. Both data sets have 30 m pixel size.

Preprocessing
Conversion to Radiance or Reflectance
Satellite images frequently require a system calibration to be applied before the data can be quantitatively
analyzed. Calibration is particularly important when comparing data sets. This is true whether comparing
data from the same sensor taken at different times or locations, or comparing data from different sensors.
System calibrations, which are based on pre-launch calculated gains and offsets, convert digital numbers
(instrument response) to radiance or reflectance above the atmosphere. ENVI contains system calibrations
for AVHRR, Landsat MSS and TM, Quickbird, and Worldview images. It is also possible to write your own
calibration functions for ENVI.

Calibration Tools in ENVI


When looking at a surface through a medium (such as the atmosphere), it is necessary to consider the effects
of the passage of radiation through the medium. ENVI provides some standard techniques for addressing
these effects. Some of these techniques also compensate for the fact that solar irradiance (the incoming solar
energy) is a function of wavelength.
There are several simple atmospheric correction methods built into ENVI. Four of these: Flat Field,
Empirical Line, Log Residuals, and Internal Average Reflectance are typically used only on hyperspectral
data sets. Dark Subtract is used on multispectral data.

50

Exploring ENVI

Preprocessing

Example Application: Vegetation Analysis

The Flat Field technique normalizes the spectrum of each pixel in the image using the average spectrum
from a region of flat reflectance within the scene. Some knowledge of the area is useful, although you can
search through the data set for flat field prospects. This technique assumes that all of the spectral features in
the flat field region are due to the atmosphere and the solar spectrum. You can use an ROI to outline the
area known to have flat reflectance and calculate its average spectrum. Then, divide the data set by this flat
field average spectrum, effectively removing the shape of the solar spectrum and atmospheric scattering and
absorptions.
The Empirical Line technique also requires some detailed knowledge of the scene. In this instance, you
collect field or laboratory reflectance spectra for two or more known target areas in the image (usually
including a dark and a bright area). Select the targeted regions using ROIs. Calculate a linear regression
between the field or lab reflectance spectra and the data radiance spectra for the target areas. This regression
line, based upon the bright and dark targets, is used to predict the surface reflectance spectrum for each
pixel.
The Internal Average Reflectance (IAR) technique can be used when working in an area for which no
ground truth data exists. Calculate the average spectrum of the entire image, then divide this spectrum into
each pixel in the image to calculate a relative reflectance.
The Dark Subtraction technique, typically performed on multispectral data, is used to remove the additive
effect of scattered light. A dark spectrum is subtracted from every pixel spectrum. The dark spectrum can be
defined as the mean spectrum of a dark region in the image, as the minimum value in each band in the
image, or as a user-defined spectrum. Commonly a user-defined spectrum, derived by examination of the
band histograms for the lowest significant values, is used for the dark spectrum.
ENVI also provides a separate Atmospheric Correction Module (ACM) that includes two routines to convert
both multispectral and hyperspectral data to reflectance. FLAASH (Fast Line-of-sight Atmospheric Analysis
of Spectral Hypercubes) is a first-principles modeling approach for applying atmospheric and solar
corrections to data sets. QUAC (Quick Atmospheric Correction) works directly with the observed pixel
spectra in a scene, without ancillary information. If a sensor does not have proper radiometric or wavelength
calibration, or if the solar illumination intensity is unknown, QUAC can still retrieve reasonably accurate
reflectance spectra as long as the scene is diverse and there are enough dark pixels to allow for a good
estimation of the baseline spectrum.

Conversion of Landsat TM Data to Reflectance


For Landsat TM Geotiff data, the factors that are used to convert a particular scene to reflectance change
through the years as the methodology of producing the data changes. Therefore, the factors that coincide
with the processing date, just before delivery to the customer, are the correct ones to use. Old factors should
not be used with recently delivered data. Therefore, we will use input from a 2009 meta data file to convert
the 1985 TM data (delivered in 2009) to reflectance.

Exercise #1: Preprocess Landsat TM Image


.
1. From the ENVI Toolbox, expand Radiometric Correction and double click on Calibrate Landsat.
The Landsat Calibration Input File dialog appears. We dont have the files open yet, so in this
dialog click on Open New File.
2. Browse to the ENVI_coursefiles\envidata\veg directory and select
L5033032_03219850812_MTL.txt and click Open. This is the metadata file that contains
the factors we will use to convert the data to reflectance. If you get an error message about
*.B60.TIF, click OK. This is Band 6 which is missing. In the Landsat Calibration Input File
dialog, we see two listings; one is the actual metadata file. Look at the File Information block and

Exploring ENVI

51

Example Application: Vegetation Analysis

Preprocessing

see in the dimensions line (Dims) it specifies one band (4061 x 3581 x 1). Select the second
listing and note that it accesses all six bands in the six separate files (we wont use band 6, the
thermal IR channel). This six band file is actually a kind of meta file or virtual file that
physically does not exist. Before you click OK, you will select a Spatial Subset.

3. Click on Spatial Subset. In the Samples field, type 711 and hit the ENTER key. Then in the To
field, type 1286. When typing in values in ENVI, is it crucial to remember to hit the ENTER key.
In some cases, ENVI will not recognize that you typed in anything unless you hit ENTER. Also,
hitting ENTER may also move you automatically to the next parameter as it does in this dialog. In
the Lines field, type 4302 to 4884. Click OK. And Click OK in the Landsat Calibration Input File
dialog.

4. The ENVI Landsat Calibration dialog appears.


5. Given the information from the meta data file about this data set, the parameters should look like
this:
Landsat Satellite Sensors: Landsat 5 TM
Data Acquisition Month: August
Data Acquisition Day: 12
Data Acquisition Year: 1985
Sun Elevation (deg): 54.2475
Calibration Type: Reflectance
6. Type Bldr_ref as the output filename and click OK. After the calibration is performed, the spatial
subset you specified should be shown in the display.

52

Exploring ENVI

Dark Subtraction

Example Application: Vegetation Analysis

7. After the calibration is performed, the spatial subset you specified should be shown in the display.
You may also see part of the full scene. If so, right click on it in the Layer Manager and select
Remove. Then with only the TM subset in the display, click on the Zoom To Full Extent icon in
the menu bar.

Creating Multiband Files


There are other ways to create a multiband file. We could create a new file that concatenates individual
bands by using the tool under Raster Management New File Builder. Another tool to do this is found
under Raster Management Layer Stacking.

Dark Subtraction
ENVIs Dark Subtraction tool corrects for atmospheric scattering. The conversion to reflectance for Landsat
(and many other multispectral data sets) does not correct for additional signal due to scattered light.
Therefore, the Dark Subtraction tool is often used on multispectral data sets. In the exercise below you will
subtract band minimums from the first 4 TM channels to remove the scattered light component.

Exercise #2: Atmospheric Scattering Correction


1. From the ENVI Toolbox, under Radiometric Correction,double click on Dark Subtraction. The
Dark Subtract Input File dialog appears.
2. Select Bldr_ref and click OK. The Dark Subtraction Parameters dialog appears.
3. Leave the default Band Minimum selected. Note that you can also specify a Region Of Interest
such as a dark shadow, or you can specify User Values that you have determined in some other way.

Exploring ENVI

53

Example Application: Vegetation Analysis

Dark Subtraction

Type Bldr_dark as the output filename, and click OK.


If you are working with a large file and need to save disk space, you can compress the output file by
enabling the Compress check box. This applies a lossless GZIP compression to the output file.
When the compressed file is opened in ENVI, it is automatically uncompressed and read in to
ENVI.
4. The corrected image will be displayed on top of the reflectance image. Color infrared images will be
displayed if you set ENVI preferences as specified in Chapter 1. To evaluate the correction click on
Display Spectral Profile. An empty Spectral Profile plot window appears. In the color display,
click on a pixel that is filled with robust, healthy vegetation. In a color infrared (CIR) image such a
pixel is bright red.
5. You should now see two spectra in the plot one from Bldr_ref, the other from Bldr_dark.
Click on the black arrowhead on the right side of the Spectral Profile window to expand it to show
the legend.

6. Note that the corrected data (green spectrum) has lower values for the first four bands and that the
values for bands one and three are now close to same value. This is what the corrected spectrum for
vegetation should look like if the atmospheric scattering component has been effectively removed.
7. Close the Spectral Profile plot window.

Digital Elevation Models


In this section, you will examine a digital elevation model (DEM) of the Boulder area.

Exercise #3: Reading and Correcting DEM data in ENVI


ENVI automatically recognizes United States Geological Survey (USGS) DEM and National Geospatial
Agency (NGA) Digital Terrain Elevation Data (DTED) formats. ENVI can also read and model other DEM
files as raster data. Because USGS DEM-format data come with positional information, ENVI automatically
performs georeferencing and mosaicking. In this exercise, you will work with a USGS DEM that has
already been converted into the ENVI image format.

54

Exploring ENVI

Dark Subtraction

Example Application: Vegetation Analysis

1. From the ENVI main menu bar, select File Open, navigate to the
ENVI_coursefiles_envidata\veg and open the Bldr_dem.dat file. The DEM image
appears in the display as the top layer.
2. After being displayed, the DEM is automatically the selected image, that means all the buttons and
sliders will operate on it. Using the Transparency slider, compare the DEM to the underlying
Landsat data. It appears that the registration is slightly off. You will correct this in a later exercise.
3. Click in the display to select it, then use the mouse roller to zoom in. Notice that there are several
scattered dark pixels which seem to be missing elevation data. Use the Cursor Value tool to
determine the data values for these pixels. You can zoom in to make this easier. You may note that
the Cursor Value dialog registers zero only when the cursor is on the pixel to the lower right of the
dark one. This is because the DEM has been reprojected. This will be changed later on. Close the
Cursor Value dialog.

4. ENVI has a tool that fills in bad values with values calculated using Delaunay triangulation from the
surrounding good elevation values. In the Search window for the ENVI Toolbox, type Replace.
Two items appear. Double click on Replace Bad Values. Notice that the location for this tool
appears under the search window (/Terrain/Replace Bad Values). The DEM Input File dialog
appears.

5. Select the Bldr_dem.dat file and click OK. The Replace Bad Data Parameters dialog appears.
6. In this DEM, all of the bad pixels have a value of 0, and no other pixels have real elevation values

Exploring ENVI

55

Example Application: Vegetation Analysis

Topographic Modeling

of 0. In the Bad Value field, type 0.


7. Type Fixed_dem as the output filename and click OK. The new file is added to the Layer
Manager List and displayed on top. Notice that the bad pixels have been replaced by reasonable
values estimated from surrounding pixels.
8. Right click on the Bldr_dem.dat file in the Layer Manager and select Remove.

Topographic Modeling
In a DEM, pixel values represent elevation. ENVIs topographic modeling tools can calculate parametric
information including slope, aspect, and shaded relief (assuming Lambertian surfaces). A plane is fit to a 3 x
3 pixel box centered over each pixel, and the slope and aspect of the plane are calculated. A root mean
squared (RMS) error image, which indicates the planarity of the nine-pixel box, can also be generated.
Slope is expressed in degrees from horizontal. Aspect is expressed in degrees from north (0 degrees is
North, 90 degrees is East, 180 degrees is South, and 270 degrees is West).
The sun elevation and azimuth must be specified to produce a shaded relief image. ENVI can calculate these
parameters, given the month, day, year, time, latitude, and longitude. Shaded-relief images help visualize
topography by simulating sunlight. Areas of direct sunlight are bright, and shadowed areas are dark.

Exercise #4: Generate Slope, Aspect, and Shaded Relief Images


1. In the Search window for the ENVI Toolbox, type topographic. Two items appear. Double click on
Topographic Modeling. The Topo Model Input DEM dialog appears.
2. Select the Fixed_dem band, and click OK. The Topo Model Parameters dialog appears.
3. All topographic measures are selected by default under Select Topo Measures to Compute.
However, highlight only the following: Slope (Degrees), Aspect, Shaded Relief, and RMS Error.
4. Click Compute Sun Elevation and Azimuth. The Compute Sun Elevation dialog appears.
Define the parameters to match those shown. After typing in a field, hitting the ENTER key will
move you to the next parameter. When finished typing in all parameters, click OK. The time and
date you are using correspond to when the Landsat data were collected. The calculated Sun
Elevation and Azimuth appear in the Topo Model Parameters dialog.

56

Exploring ENVI

Image to Image Registration

Example Application: Vegetation Analysis

5. Type Bldr_topo as the filename and click OK. Three of the four new products are displayed as a
color image. Right click on the Bldr_topo file in the Layer Manager and select Remove.
6. Click on the Data Manager icon . Scroll down to Bldr_topo, right click on Slope and choose
Load Grayscale. Click on the Cursor Value icon
and move the cursor around the image to
view the Data values for this layer. Right click on the Slope image in the Layer Manager and select
Remove. Next display and examine the Aspect image. Remove it from the display when you are
finished.
7. In the Data Manager right click on Shaded Relief and select Load Grayscale. Use the
Transparency slider to view the TM scene below it. The registration of the two images is fairly close
but you will go through the process of registering the TM scene to the Shaded Relief image in the
next exercise.
8. Right click on View in the Layer Manager and select Remove All Layers. Close the Cursor Value
dialog.

Image to Image Registration


In subsequent sections of this chapter, you will use data derived from the DEM to analyze data from the TM
image. To do this, you first need to register the two images.

Exercise #5: Register the Landsat TM Image to the DEM Image


1. Clear what you have typed in the Toolbox search window. The full list of tools appears.
2. In the Toolbox click Geometric Correction Registration Registration: Image to Image.
The Select Input Band from Base Image dialog appears.
3. Select the Shaded Relief band of Bldr_topo as the Base Image and click OK.
4. In the Select Input Warp File dialog, select Bldr_dark and click OK.
5. In the Warp Band Matching Choice dialog, select Band 3 and click OK.
6. An ENVI Question appears asking if you would like to select a tie points file. One has not been
created so click No.
7. The Automatic Registration Parameters dialog appears. Let all parameters default and click OK.

Exploring ENVI

57

Example Application: Vegetation Analysis

Image to Image Registration

The Ground Control Points Selection dialog appears along with the Base Shaded Relief Image,
Band 3 of the file to warp, and the Image to Image CGP List showing all the automatically
generated tie points.
With no roads or buildings, etc. visible in the base image to use as tie points, what type of feature
defines the tie points here?
8. Click on point #1+ in the Image to Image GCP List. This GCP will be centered under red crosshairs
in both Zoom windows. Does the location look good in both the base and the warp image? Click on
several other points to view them in the Zoom windows. Although some points appear to be welllocated, some points are not. Rather than taking the time to edit these points you will use Ground
Control Points (GCPs) that have been provided.
Image registration is explored in detail later in this course. You will see that fractional pixel
locations can be selected. The pixel fraction available is proportional to the zoom factor used in the
Zoom window.
9. From the Ground Control Points Selection dialog menu bar, select Options Clear All Points.
10. From the Ground Control Points Selection dialog menu bar, select File Restore GCPs from
ASCII. Navigate to the envidata\veg directory, select Bldr_dem.pts, and click Open.
Notice that these GCPs are now shown in each image display. You may also notice that the overall
RMS Error is much lower now, less than one pixel.
11. From the Ground Control Points Selection dialog menu bar, select Options Warp File. The
Input Warp Image dialog appears.
12. Select Bldr_dark and click OK. The Registration Parameters dialog appears.
13. Enter or select the following parameters:
Polynomial as the Warp Method with degree 1
Nearest Neighbor resampling.
1 for both the Upper Left X and Upper Left Y
356 for number of samples. This is the same as the DEM.
464 for number of lines. This is the same as the DEM.
These values are the number of samples and lines in the DEM. It is important to use these exact
settings to ensure that the resulting warped image will be the same size as the DEM. Double check
them before proceeding!

58

Exploring ENVI

Building Masks

Example Application: Vegetation Analysis

14. Type Bldr_warp.dat as the warped data file output name, and click OK. The resulting warped
image is displayed in the ENVI 5.0 interface. Close both external ENVI Classic displays.
15. Click on the Zoom to Full Extent icon on the menu bar.
16. Open the Data Manager, right click on the Shaded Relief band of Bldr_topo and select Load
Grayscale. Adjust the transparency of the overlying Shaded Relief to check the registration.

Building Masks
A mask is a binary image that consists of values of 0 and 1 only. When a mask is used with a processing
function, the areas with values of 1 are processed, while the masked values (values of 0) are not included in
the calculation.
Image masks can be defined using a data value, data ranges, ROIs, vectors, or annotation. In this exercise,
data ranges define the masks. Mask bands can be applied during several ENVI functions, including
statistics, classification, unmixing, principal component analysis, continuum removal, and spectral feature
fitting.
In the following exercise, you will create a mask that blocks out areas facing away from the sun (areas in
shadow) and areas with lower elevations. Masks for other elevation ranges have already been calculated for
you. You will use these masks when calculating statistics for different elevation categories in the study area.

Exercise #6: Make Masks of Terrain Categories

Exploring ENVI

59

Example Application: Vegetation Analysis

Building Masks

1. Display Fixed_dem as a gray scale image.


2. In the search window for the ENVI Toolbox, type Mask. Then double click Build Mask.
3. The Mask Definition dialog appears. You need to specify the number of samples and lines for the
mask. Because the mask will be used on Bldr_warp.dat and bldr_topo, the dimensions of
the mask should equal those files. In the Data Manager, choose one of those files then expand File
Information. You will see that the number of samples and lines equals 356 and 464. Type those
values into the Mask Definition dialog.
4. From the Mask Definition dialog menu bar, select Options Import Data Range. The Select
Input for Mask Data Range dialog appears.
5. Select the bldr_topo image and click the Spectral Subset button. The File Spectral Subset
dialog appears.
6. Select the Aspect band and click OK to return to the Input for Mask Data Range dialog.
7. Click OK. The Input for Data Range Mask dialog appears.
8. In the Data Min Value field, type 12 as a minimum aspect value. In the Data Max Value field,
type 192 as a maximum aspect value (these are the aspects which face toward the sun), then click
OK to return to the Mask Definition dialog.
9. From the Mask Definition dialog menu bar, select Options Import Data Range. The Input for
Mask Data Range dialog appears.
10. Click the Select New Input button. The Select Input for Mask Data Range dialog appears.
11. Select the Fixed_dem band and click OK. The Input for Mask Data Range dialog appears.
12. In the Data Min Value field, type 2000 as a minimum elevation value. Leave the Data Max Value
field blank and click OK to return to the Mask Definition dialog.
13. From the Mask Definition dialog menu bar, select Options Selected Attributes [Logical AND].
14. You want to use all pixels that fall within the above aspect and elevation ranges in calculations
when this mask is applied. In other words, pixels with these values will equal "1" in the masked
image. To do this, select Options Selected Areas On from the Mask Definition dialog menu.
15. Type high_elev as the filename and click Apply. The resulting mask image appears in the
display.

60

Exploring ENVI

Normalized Difference Vegetation Index (NDVI)

Example Application: Vegetation Analysis

16. Click Cancel to close the Mask Definition dialog.


17. Open and display the other masks (med_elev and low_elev) in the
ENVI_coursefiles\envidata\veg directory.
18. When you are finished examining the mask images, right click on the View item in the Layer
Manager and select Remove All Layers.

Normalized Difference Vegetation Index (NDVI)


The Normalized Difference Vegetation Index (NDVI) is a commonly used vegetation index that uses red
and near-infrared image bands to derive a single image representing the abundance of green vegetation.
ENVI provides two different methods for calculating NDVI.

The NDVI routine is available in the Spectral Vegetation menu. It automatically calculates
NDVI for AVHRR, Landsat MSS, Landsat TM, SPOT, and AVIRIS data.

If you are working with data from another sensor, you can manually enter the NDVI bands in the
NDVI Calculation Parameters dialog, or you can instead use the Band Math tool.

Exercise #7: Calculate the NDVI


1. Right click on Bldr_warp.dat in the Data Manager and select Load CIR. Click on the Zoom
To Full Extent icon.
2. In the search window for the ENVI Toolbox, type ndvi. Then double click NDVI.
3. The NDVI Calculation Input File dialog appears.
4. Select the file Bldr_warp.dat and click OK. The NDVI Calculation Parameters dialog appears.

Exploring ENVI

61

Example Application: Vegetation Analysis

Statistics

5. Ensure the Input File Type drop-down list reads Landsat TM. The NDVI Bands are automatically
set to Band 3 as red and Band 4 as Near IR for this sensor. If you were to change the Input File
Type setting, the NDVI Bands would automatically change accordingly.
6. Type Bldr_NDVI.dat as the filename, and click OK. The NDVI result is displayed.
7. Use the Transparency slider, or Blend, Flicker, or Swipe to compare the areas with high NDVI
values to the red areas in the RGB image. Notice that areas in shadow tend to have relatively high
NDVI values.
Are the high NDVI values in shadows real? Is NDVI dependent on illumination, or relatively
independent from its effects?

Statistics
Now you will collect NDVI statistics for the high elevation area previously defined using your mask
(statistics for the other elevations have already been calculated for you). You will then be able to compare
statistics for the different elevation categories.

Exercise #8: Calculate NDVI Statistics Using Masks


1. In the search window for the ENVI Toolbox, type statistics. Then double click Compute Statistics.
2.

The Compute Statistics Input File dialog appears. Select the file Bldr_NDVI.dat and click the
Select Mask Band button. The Select Mask Input Band dialog appears.
Note: You can also create masks using the Mask Options drop-down button on the Select Mask
Input Band dialog.

3. Select the high_elev Mask Band, click OK and OK.


4. In the Compute Statistics Parameters dialog accept the default settings, and click OK. The Statistics
Results dialog appears.
This dialog shows the minimum, maximum, mean, and standard deviation of the unmasked pixels in
plot and text format. Compare the values for the different elevations by filling out the table below.

Elevation

Mean NDVI

Low (1500 to 1700 m)

0.42

Medium (1700 to 2000 m)

0.46

High (greater than 2000 m)

Does the average green vegetation abundance (as indicated by NDVI) seem to vary with elevation
in this region? Can you think of additional ways you could use masking to further examine the
relationship between vegetation density and topography?
5. When you are finished looking at the statistics, close the Statistics Results dialog.

62

Exploring ENVI

3D SurfaceView

Example Application: Vegetation Analysis

3D SurfaceView
In the last section, you saw that in late summer when this scene was taken there was more green vegetation
in the Boulder area at higher elevations than at lower elevations.Next you will use ENVIs 3D SurfaceView
tool to visualize the relationship between elevation and the abundance of green vegetation. The 3D
SurfaceView tool allows you to drape images over a 3D surface generated from the DEM. It also allows you
to zoom in and out on and rotate the 3D view, and to create animated fly-through sequences.

Exercise #9: 3D SurfaceView


1. In the search window for the ENVI Toolbox, type 3d. Then double click 3D SurfaceView.
2. In the Select 3D SurfaceView Image Bands Input dialog, select Bands 4, 3, 2 of Bldr_warp.dat
to display as RGB. Then click OK. This CIR composite, where areas of green vegetation appear
red, is displayed in a separate 3-window display group.
3. In the Associated DEM Input File dialog, select the Fixed_dem band and click OK. The 3D
SurfaceView Input Parameters dialog appears.
The entire image is used as the overlay image on the DEM unless both the image and DEM files are
georeferenced. If both the files are georeferenced, then only the part of the image that overlaps with
the DEM is used. If a spatial subset is chosen for the DEM, then the georeferenced image is
automatically subset to match. The spatial resolutions of the two files do not need to be the same.
It is possible to permanently associate a DEM with an image file by editing the files ENVI header.
This facilitates functions like the 3D SurfaceView.
4. Select 64 and Full for the DEM Resolution. This is the number of pixels that will be used along the
longest dimensions of the DEM in the 3D SurfaceView window. You want to use the lowest
resolution (64) while determining the best flight path, then you can switch to the higher resolution to
display your final fly-through sequence. Using the higher DEM resolutions significantly slows the
display and should only be used on fast machines.
5. In the DEM min plot value field, type 1500. This specifies that DEM values lower than 1500
meters are not plotted. For example, if you were using the original DEM image, which had scattered
pixels with values of 0, and did not set a DEM minimum plot value, those zeros would be
interpreted as elevation values, and the surface would dip to zero at those pixels.
6. Set the Vertical Exaggeration field to 3.0.
7. Leave all other parameters at their default values and click OK. The 3D SurfaceView window
appears. You can resize this window by clicking and dragging a corner of the window.
8. Use the mouse to interactively rotate, translate, and zoom into the surface. The mouse button
functions are listed below.

Exploring ENVI

Mouse Button

Action

Left

Click and drag to rotate x/y axis.

Middle

Click and drag to translate image.

Right

Click and drag to the right to zoom in.


Click and drag to the left to zoom out.

63

Example Application: Vegetation Analysis

3D SurfaceView

9. From the 3D SurfaceView window menu bar, select Options Surface Controls. The resulting
dialog allows you to fine tune the rotation, scale, and translation of the plot.
10. Use the arrows and plus and minus signs to change the view a small amount at a time. Then try
typing in relatively large numbers in the Inc field and use the arrows to jump quickly from one view
to another.

The 3D view can be reset to its original position using the 3D SurfaceView window menu bar,
Options Reset View option.
11. Experiment viewing one of the peaks from all sides. Notice where the shadows fall.
Where do you suppose the sun is in the sky? Remembering that green vegetation appears red in this
RGB combination, can you see a trend in average green vegetation with elevation? Does this agree
with the results you saw in the last exercise?
12. Explore each of these options available from the 3D SurfaceView menu bar:
Change the color of the background from white to black, by selecting Options Change
Background Color. The resulting dialog allows custom RGB mixing or use of preset system
colors.
Smooth the 3D view so that the draped image appears less pixelated when you zoom in, by
selecting Options Bilinear Interpolation.
13. Next you will drape the NDVI image over the DEM. Double click again on 3D SurfaceView in the
ENVI Toolbox.
14. In the Select 3D SurfaceView Image Bands Input dialog, Click on the NDVI band three times to
load it as R, G, and B. Click OK.
15. In the Associated DEM Input File dialog, select the Fixed_dem band as the DEM that is used to
make the 3D surface, and click OK. The 3D SurfaceView Input Parameters dialog appears.

64

Exploring ENVI

3D SurfaceView

Example Application: Vegetation Analysis

16. Select 64 and Full for the DEM Resolution.


17. In the DEM min plot value field, type 1500.
18. Set the Vertical Exaggeration field to 3.0. Leave all other parameters at their default values and
click OK.
19. Spend a couple of minutes moving around the NDVI 3D SurfaceView window. Again, try viewing
one of the peaks from all sides.
20. Compare this NDVI 3D SurfaceView plot to the 3D SurfaceView plot of the color-infrared
composite.
Can you see shadows in this image? Remember that the NDVI image can be thought of as an image
of green vegetation. Notice how the plains have areas with very high values (lots of green
vegetation) but also areas with very low values (little green vegetation). The mountains seem to
have more uniformly intermediate values. Does this help explain the relationship between
vegetation and elevation that you saw in the last exercise?
Is it easier to visualize where the green vegetation is in the NDVI 3D window? Notice that in the
NDVI 3D window, the North-facing slopes seem to have relatively high NDVI values. What can
you see in the other 3D window that may help explain this effect?
21. Close the NDVI 3D SurfaceView but leave the color-infrared 3D SurfaceView open.

Exercise #10: Advanced 3D SurfaceView Options


1. From the 3D SurfaceView window, select Options Motion Controls. The SurfaceView Motion
Controls dialog appears.
2. In this dialog, the Motion is set to User Defined Views by default. From the SurfaceView Motion
Controls dialog menu bar, select Options to view the Motion selection.
3. Click the Add button in the SurfaceView Motion Controls dialog to add your view to the animation.
The view is listed as Flight Path View #1 in the dialog.
4. Move around in the 3D SurfaceView window, and select Add in the SurfaceView Motion Controls
dialog to add Views to the animation path.
5. After you have added at least two Views, click the Play Sequence button to view your animated
fly-through. Continue adding, deleting, or replacing Views until you have five or six Views that you
like in your animation. Clear will delete all of your Views.
6. Increase the number of Frames to 100 and replay the animation. More frames will result in a longer
animation.

Exploring ENVI

65

Example Application: Vegetation Analysis

3D SurfaceView

7. The Options menu in the SurfaceView Motion Controls dialog can be used to control the
continuous loop play sequence and other playback parameters.
The Options Animate Sequence option creates the animation sequence in a new, separate
window.
8. You can create a fly-through animation from the 3D SurfaceView window by drawing an
annotation line in a 3-window display and then importing that line to be used as a flight path. One
way to bring up a 3-window display group is to open the SPEAR folder in the Toolbox and run
SPEAR Anomaly Detection. In that workflow, select the Boulder scene as input, then proceed by
hitting the Next button twice (the workflow panel may be behind the ENVI interface at some point).
Two 3-window displays will appear. Close the one showing the RXD result. Then go to the 3window display containing the Boulder scene and select Overlay Annotation from the Display
group menu bar.
9. From the Annotation dialog menu bar, select Object Polyline.
10. Click the Scroll radio button. This setting controls in which window the annotation is drawn.
11. Click several times with the left mouse button to draw a line in the Scroll window. This serves as
your flight path through the image. When you are finished drawing the line, click the right mouse
button. A diamond-shaped symbol appears near the center of the finished line, indicating that the
object is no longer being drawn. Click the right mouse button again to accept the line (or, if you
dont like what you drew, click the middle mouse button to discard the line and redraw it).
12. Once an annotation line has been drawn and accepted, it can be imported into the 3D SurfaceView
window. From the 3D SurfaceView window containing the RGB Bldr_wrp image, select Options
Motion Controls. The SurfaceView Motion Controls dialog appears.
13. From the SurfaceView Motion Controls dialog menu bar, select Options Motion: Annotation
Flight Path.
14. Select the Input Annotation from Display option and click OK. The 3D SurfaceView Motion
Controls dialog is updated and the flight path is also shown in the 3D SurfaceView window.
15. . Information about the imported annotation should be listed in the field at the top of the motion
controls dialog. If it is not, from the 3D SurfaceView Motion Controls dialog menu bar, select File

66

Exploring ENVI

3D SurfaceView

Example Application: Vegetation Analysis

Input Annotation from Display.

16. In the Flight Clearance field, type 1000 meters (the clearance value uses the same units as the DEM,
which in this case is meters).
17. In the Flight Look Angles area, set the Up/Down field value to -45 (you will be looking 45 degrees
down from horizontal) and the Left/Right value to 10 (you will be looking 10 degrees to the right).
18. Click the Play Sequence button to view the animation. You may need to adjust your parameters to
smooth out the flight. For example, change the Flight Smooth Factor to 100 and the number of
Frames to 1000. Play the sequence again. Note that you can save this animation as an mpeg by
selecting File Save Sequence as MPEG. Close the 3D SurfaceView Motion Controls dialog.
19. You can view the surface of your 3D view panoramically as if you were standing in the image.
From the 3D SurfaceView window menu bar, select Options Position Controls. The
SurfaceView Position Controls dialog appears.
20. In the Sample field, type 334 and hit the ENTER key. In the Line field, type 381 and hit the
ENTER key. This is a location in the city of Boulder.
21. Set the Azimuth to 270 degrees. This sets the view directly West.
22. Set the Height Above Ground to 200 meters. This is the distance from which you will look down
on the image. Again, the height units are the same as the DEM elevation units.

Exploring ENVI

67

Example Application: Vegetation Analysis

Skills Check

23. Change the Height Above Ground to 500 meters and drag the Elevation slider bar to -10. The
Elevation setting determines your perspective from the horizontal. Positive values have you look up,
with negative values you look down. The Use Offset toggle is used if the image is a subset and you
want to refer to the larger scene from which it was subset.
24. Close the 3D SurfaceView window, and all 3D and annotation dialogs. Also close the 3-window
display group and the SPEAR Anomaly Detection workflow if it is still open. .
25. Open up the Data Manager and click on Close All Files

Skills Check
At this point you should:
Calibrate Landsat and correct for scattered light
Know how register an image
Run the Topographic Modeling tool to extract products from a DEM
Create a mask
Drape an image over a 3D surface

Self Test
1. After you convert a multispectral data set to reflectance do you still need to run dark object
subtraction?

68

Exploring ENVI

Chapter 5:

Vector Layers

Learning Objectives.................................................................................................................. 70
Prerequisites ............................................................................................................................ 70
Required Tools for Completing This Module ............................................................................. 70
Associated Data ....................................................................................................................... 70
Working with Vectors in ENVI ................................................................................................... 70
Image Reprojection .................................................................................................................. 71
Editing Vector Layers ............................................................................................................... 72
Linear Feature Extraction ......................................................................................................... 74
Skills Check ............................................................................................................................. 78
Self Test ................................................................................................................................... 78

Exploring ENVI

69

Vector Layers

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Overlay vector layers onto imagery
Edit vectors

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. Also you should know how to
display an image in ENVI and work with the Layer Manager.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

cities.evf, roads.evf, and counties.evf. ENVI vector files created from ESRI
shapefiles. They cover the United States.
washdc_x.bil A SPOT image of the Washington DC area.
washington-e and washington-w two USGS DEM the cover Washington DC.

Working with Vectors in ENVI


In any spatial data set, data can be categorized into two main types. The first, raster data, is the type of data
that you have been working with up to this point. Image and DEM data are examples of this data structure.
Raster data consist of a regular grid (matrix) of numbers that populate cells (pixels) of known size and shape
oriented in a regular pattern of rows and columns. In most cases, these grids are projected into a known
coordinate system so that information can be compared between grids. Groups of cells (pixels) with the
similar values represent similar features on the image. Spatial data can also be represented in the form of
vector layers, which are the focus of this chapter.
A digitized road map is an example of this type of data structure. Vector data utilize a coordinate-based
system to represent and locate physical elements such as points, lines, and areas (polygons). In all cases
each feature is expressed as an ordered list of x,y coordinate points (vertices). Lines (arcs) are recorded as a
series of vertices with ordered x,y coordinates; areas (polygons) are recorded as a series of x,y coordinates
defining line segments that enclose an area. Only the locations of the vertices that outline or identify the
points or lines are stored, rather than the location of all the points that make up each physical feature.
Because of this, vector data structures are a much more compact way to store point, line, or area feature
information. Unlike raster data, where attribute information is associated with each individual grid cell, in
vector data, attributes are associated with each feature (point, line, or polygon) and not each individual
vertex.
Vector data are imported into ENVI automatically. Currently, ENVI can read the following vector formats:
ArcView shapefile (.shp)
ARC/INFO interchange format (.e00)
AutoCAD (.dxf)
MapInfo interchange format (.mif)
Microstation or Intergraph DGN (.dgn)
USGS DLG

70

Exploring ENVI

Image Reprojection

Vector Layers

USGS SDTS
ENVI vector file (.evf)

All incoming vector data is converted by ENVI into ENVI Vector File (.evf) format. The conversion is
done because the EVF format is the most efficient format for storing and manipulating vector information in
ENVI. Native vector formats are converted to the EVF format and either stored in memory or written out to
a file according to the your preference. It is faster to process data in the EVF format than in its original,
native vector format.

Image Reprojection
A multispectral SPOT scene of Washington, D.C. with a spatial resolution of 20 m will be used in this
lesson. To overlay vectors stored as map coordinates onto an image, the image must be georeferenced. In
other words, the image must be in a valid map projection, and the image header must contain information
about that map projection. In addition, the image should be in the same projection as the vector data, so you
will change the projection of the SPOT image to match the vector layers.

Exercise #1: Displaying Vector Data and Georeferencing Image Base


1. From the ENVI menu bar, select File Open. Navigate to the envidata\vectors directory
and open cities.shp, roads.shp, and counties.shp. The vector layers are listed in the
Layer Manager and loaded into the display. These vectors also come with the ENVI installation.
2. Move your cursor around the image and note the coordinate and projection information in the status
bar at the bottom. ENVI can automatically read projection information from most vector files.
3. The Washington, D.C. SPOT image is in the UTM map projection, but the map projection
information is not present in the image header so ENVI does not read the image as georeferenced.
From the ENVI Toolbox, expand Raster Management and double click on Edit ENVI Header. In
the Edit Header Input File dialog, click Open New File, navigate to the envidata\vectors
folder, select washdc_x.bil and click Open.
4. Click OK in the Edit Header Input File dialog
5. Click the Edit Attributes drop-down button, and select Map Info. The Edit Map Information
dialog appears.
6. In the Image X and Image Y fields, type 1. This indicates that the reference pixel (the pixel for
which you will enter map coordinates) is located in the upper-left corner of the image.
7. Click the Change Proj button. The Projection Selection dialog window appears.
8. Select UTM which is the map projection of the washdc_x.bil SPOT image. In the Zone field,
type 18. This is the UTM zone for Washington, D.C.
If you did not know the correct UTM zone but knew the correct latitude and longitude, you could
have clicked the Set Zone button, entered the latitude and longitude coordinates and have ENVI
calculate the correct UTM zone for you.
Click OK to return to the Edit Map Information dialog.
9. The UTM Zone 18 map projection should now be listed, where an arbitrary map projection was
previously listed. In the E field, type 301214.00. In the N field, type 4337515.00.
10. In the X Pixel Size and Y Pixel Size fields, type 20. Leave the Map Rotation at 0.00 and click OK.
The Header Info dialog appears.

Exploring ENVI

71

Vector Layers

Editing Vector Layers

.
11. Click OK in the Header Info dialog. The SPOT image will be listed in the Data and Layer
Managers. In order to use the image as a base layer it has to be displayed first. Also, it should be in
the same geographic coordinate system as the vector data (Latitude/Longitude), so first you will
change the projection of the SPOT image to match the vector layers. First click on the View listing
in the Layer Manager and select Remove All Layers.
12. Under Raster Management in the ENVI Toolbox double click on Project Raster. Click Browse
and select washdc_x.bil in the Dataset to Reproject dialog. Click OK.
13. Click on Select Output Coordinate System and click on Geographic Coordinate Systems to
expand that folder. Scroll down and expand the World folder. Then choose WGS 1984. Click OK.
14. For Output Dataset, type in Washdc_wgs.dat and click OK in the Project Raster Tool dialog.
15. From the Data Manager, load Washdc_wgs.dat as a (3,2,1) RGB image. Adjust the contrast of
the image. Linear 1% or 2% works well for a stretch.
16. In the Data Manager, select the three vector files, right click on them and choose Load Files. After
the datum of the vector files (NAD 83) changes to match that of the image (WGS084), the vectors
will overlay the image. In the next exercise you will edit them to make them more obvious.

Editing Vector Layers


The following vector display characteristics can be modified:
Color
Line style (dash, solid, dotted, etc.) and thickness
Polygon fill (solid, lined, dotted, etc.), and orientation and spacing of fill lines

72

Exploring ENVI

Editing Vector Layers

Vector Layers

Point symbol and symbol size


Whether it is drawn

Exercise 2: Editing Vector Layers and Their Attributes


1. The icon for the currently active vector layer is enclosed in a red box in the Layer Manager. If cities
is not the active layer, right click on it and choose Set as Active Layer.
2. Right click on cities.shp and choose Properties.
3. Click on the Color box, and then on its drop-drown list. From the color pallet choose yellow.
4. Click on the Symbol and then on its drop-drown list, select Asterisk as the symbol. Change the
Symbol Size to 20.
5. The new properties should have updated so click OK to close the Properties dialog.
6. Right click on cities.shp again and choose View Attributes.
7.

Click on one of the asterisks in the display and the city will be highlighted in the Attribute Viewer.
If you dont see the city listing at first, click on the asterisk again. If you click on the row number
for a city listed in the Attribute Viewer, its asterisk will be highlighted in the display. Use the scroll
control under the attribute table to view all of the attribute fields.
You can use the buttons at the bottom of the Attribute Viewer to navigate to different records. If
you know the number of the record you want to go to, type it into the field provided and press the
ENTER key.

8. The attribute table can be manipulated. Change the column width by clicking and dragging on the
division between the columns in the header row in or out (the cursor icon changes to a doubleheaded arrow).
9. You can sort the attribute information by column. To alphabetize the attribute table by city name,
select the CITY_NAME column in the column header row, then, right click and select Sort by
selected column forward or Sort by selected column reverse. Note that you can also Sort by
original order.
10. Close the Attribute Viewer.
11. Right click on counties.shp and choose Properties. Change the Color to a bright green. Click
OK to close the Properties dialog.
12. Right click on roads.shp and choose Properties. Click on the Color line, then click on the pulldown menu and select Custom Color. Choose cyan and then click Add to Custom Colors. Click
OK and you will see cyan at the bottom of the color palette. Click on it there and the roads will be
updated.
13. Change the road Thickness to 2. Click OK to close the Properties dialog.

Editing Vectors
Many of the road vectors in your display are roughly drawn and they do not always occur at the same
locations in the vector layer as they do in the image. For example, look in the upper left corner of the SPOT
image. In this next exercise, you will edit existing vectors and add additional vectors.
14. Right click on roads.shp and choose Set as Active Layer.
15. In an area where you see road vectors, zoom in so that you can see the road detail in the image
below. You can use the Go To tool in the ENVI menu bar to go to sample 690 and line 860. (type

Exploring ENVI

73

Vector Layers

Linear Feature Extraction

690p,960)
16. From the ENVI menu bar, click on the Vertex Edit icon.
17. In the display find an area where the road is not in the right place. Click on one of the vertices for a
road vector. The vector should now be highlighted. Drag one of the vector nodes to a new location.
Add more nodes to the road by right clicking on where you would like a vertex to be, and selecting
Insert Vertex. Continue to insert vertices and if necessary, drag nodes to correct locations for the
road. When you are satisfied with your edited road vector, right click and select Accept Changes. If
you want to connect two polylines, position the end of one close to the other, right click and select
Snap to Nearest Vertex. Then right click and select Accept Changes. Continue editing a few more
road vectors.
Some major highways which are visible in the SPOT scene do not have road vectors associated with
them. In the next step, you will make a new road vector for one of these highways.
18. From the ENVI menu bar, select Vector Create. You should already be in polyline mode because
this is the vector type for the roads layer.
19. Click in the display to draw a new road vector. Click several times to place vertices for the new
road. When you are satisfied with your new road, right click and select Accept.
20. When you are finished editing, right click on the roads layer in the Layer Manager and select Save.
Click Yes to overwrite the file. Click on the Select icon in the ENVI menu bar to get out of vector
editing mode.

Linear Feature Extraction


ENVI provides a tool called the Intelligent Digitizer that extracts linear features (roads, coastlines, lake
boundaries, and rivers) as vector data. With Intelligent Digitizer, you place seed points along the path of a
feature in gray scale or multi-band imagery, and ENVI automatically finds the intermediate points. By using
this method, Intelligent Digitizer reduces the number of mouse clicks you use to extract a feature, resulting
in saved time and improved accuracy over traditional heads-up digitizing.
With Intelligent Digitizer, you can perform automatic post-processing procedures to improve the quality of
the feature extractions, and you use ENVIs Vector Parameters dialog to manage vectors, to perform basic
vector editing, and to convert vectors to external formats such as shapefiles.

Exercise 3: Using the Intelligent Digitizer to Extract Roads


When extracting linear features, it is best to create separate layers for different feature types. The following
exercise shows you how to create a new layer and extract roads with intersections and a highway with
overpasses. You will use the Washington, D.C. SPOT data for this exercise, although ideally you should use
high-resolution satellite or aerial imagery for accurate placement of features.
1. From the ENVI Toolbox, expand the Vector and double click onIntelligent Digitizer. The
Intelligent Digitizer Input File dialog appears.
2. Select washdc_wgs.dat file, and click OK. ENVI automatically loads all three bands into a new
display group for use with the Intelligent Digitizer. The Vector Parameters dialog also opens, with
menu options for Intelligent Digitizer enabled. ENVI adds a new layer named Intelligent Digitizer:
New Layer to the Available Vectors Layers area of the Vector Parameters dialog.
3. From the Vector Parameters dialog menu bar, select Mode Intelligent Digitizer Parameters.
4. In the Intelligent Digitizer Parameters dialog, set the Linear Feature Width (Pixel) to 15.00 for

74

Exploring ENVI

Linear Feature Extraction

Vector Layers

road extraction. Click OK.


5. In the Vector Parameters dialog, click the Off radio button to temporarily turn off vector editing.
6. From the Display group menu bar, select Tools Pixel Locator. The Pixel Locator dialog appears.
7. In the Sample field, enter 1507. In the Line field, enter 805. Click Apply, then close the Pixel
Locator dialog.
8. Enlarge the Zoom window so you can see all of the overpass and some of the BaltimoreWashington Parkway that extends to the northeast.

9. From the Vector Parameters dialog menu bar, select Edit Edit Layer Properties. The Edit
Vector Layers dialog appears.
10. Set the Thick value to 3. Right-click in the Color box, and select Items 1:20 Red. Click OK.
11. In the Vector Parameters dialog, click the Zoom radio button to turn on vector editing in the Zoom
window.
12. In the Zoom window, begin left-clicking at intervals to add seed points that mark the road. ENVI
automatically connects one seed point to the next, automatically adding vertices between the seed
points as needed. Here are some tips for extraction:

For road centerline extraction, select seed points near the road centerline.
For sharp curves in the road, select seed points at the sharp curves.
If the placement of a seed point does not extract the feature as desired, middle-click to remove
the last seed point, then select a new seed point closer to one that you removed. Clicking on a

Exploring ENVI

75

Vector Layers

Linear Feature Extraction

location closer to the previous seed point will likely give a better result. You can middle-click
more than once to remove seed points in reverse order, one at a time.
At intersections, extend the start or end node beyond the point where the two roads intersect.
You will use automatic post-processing in a later step to remove dangling lines.
In areas that do not provide sufficient contrast between the feature and the background, or in
areas of roads with overpasses, press and hold the Shift key to temporarily disable intelligent
mode, then left-click to define the feature through the area. When you are past the area, release
the Shift key to resume intelligent mode.

13. When you have enough seed points added to define a road, right-click in the Zoom window to set
the final seed point, then right-click again and select Accept New Polyline. Optionally, if you are
extracting a road that is near another road (or roads) that is already extracted, you can snap the
node(s) to the nearest polyline(s). To do this, select Snap Start Node to Nearest Polyline, Snap
End Node to Nearest Polyline, or Snap Both Ends to Nearest Polylines from the right-click
menu.
14. Repeat adding seed points for each road you want to extract.

15. From the Vector Parameters dialog menu bar, select Edit Save Changes Made to Layer.
After you extract polyline features, you can apply ENVIs automatic post-processing cleanup tool to
create intersections between polylines that cross one another, and to correct overshooting (dangling)
polylines.
16. In the Vector Parameters dialog, right-click on Intelligent Digitizer: New Layer, and select Linear
Feature Cleanup. The Linear Feature Cleanup Parameters dialog appears.
17. The Dangle Length Tolerance (Pixels) default value is 20.00. ENVI removes any dangling
polylines shorter than this value during automatic linear feature cleanup. You can change this value
in the dialog, if desired.
18. Click OK. ENVI removes any dangling polylines and creates intersections between crossing
polylines. When complete, ENVI overlays the modified layer on the original layer (using a different

76

Exploring ENVI

Linear Feature Extraction

Vector Layers

Current Layer color). In the Vector Parameters dialog, ENVI adds the new layer named Intelligent
Digitizer: New Layer_clean to the Available Vectors List.
19. When you are finished experimenting with Intelligent Digitizer, close the 3-window display group
and all dialogs.

Exercise 4: Importing DEMs


1. From the ENVI menu bar, select File Open As Digital Elevation USGS DEM.
2. The DEM for the Washington area is broken into 2 pieces (East and West) and must be assembled
by mosaicking them together. Navigate to the envidata\vectors directory, and select both the
washington-e and washington-w files, then click Open. The USGS DEM Input Parameters
dialog appears.
3. Ensure that both DEM files are listed and that the Mosaic Files radio button is set to Yes. Type
washdc.dem as the output filename and click OK. When asked if the dimensions of the output
DEM are 2401 x 1201, answer Yes. ENVI mosaics the two DEMs together and displays the result.
Zoom out to see the DEM; it extends beyond the SPOT image extent.
4. Click on the Cursor Value icon and roam around in the image. Data values for the DEM correspond
to the elevation in meters relative to mean sea level.

Exercise 5: Overlaying Vectors on a 3D SurfaceView


1. Before 3D SurfaceView will display vectors, a 3-window display group has to be open with vectors
overlying an image. One way to do this is to use the Intelligent Digitizer tool. From the ENVI
Toolbox, expand the Vector listing and double click onIntelligent Digitizer. The Intelligent
Digitizer Input File dialog appears.
2. Select the washdc_wgs.dat file, and click OK.
3. Click the Off radio button for the Vector Parameters dialog. Then in that dialog select File Open
Vector File.
4. In the Select Vector Filenames dialog, select cities.shp, roads.shp, and counties.shp
and click open. Then click OK in the Import Vector Files Parameters dialog.
5. If you want to make the vectors easier to see, edit them using the techniques in exercise 2.
6. From the ENVI Toolbox, expand the Terrain folder and double click on 3D SurfaceView.
7. In the Associated DEM Input File dialog, select the washdc.dem image band, and click OK. The
3D SurfaceView Image Parameters dialog appears.
8. Accept the defaults, and click OK.
9. From the 3D SurfaceView menu select Options Import Vectors.
10. After the vectors are imported, you may see that some polylines appear to go beneath the
topography. This is because of the vertical exaggeration that is the default for this window. To
change this, click Options Surface Controls. Then in the 3D SurfaceView Controls dialog,
decrease the Vertical Exaggeration.
The color composite image in the 3D SurfaceView window may be different than the image shown
in the main display. This is because the header file for washdc_wgs.dat does not have
wavelengths specified for the bands. Can you think of a way to display the SPOT scene as a CIR
image in the 3D SurfaceView window?

Exploring ENVI

77

Vector Layers

Skills Check

11. When you are finished exploring the 3D SurfaceView, close the display group and the 3D
SurfaceView window.
12. Right click on the View listing in the Layer Manager and select Remove All Layers.

Skills Check
At this point you should:
Be able to import vector layers into ENVI
Know how to Edit vectors

Self Test
1. What vector formats can be imported into ENVI?

78

Exploring ENVI

Chapter 6:

Regions of Interest and


Classification Techniques

Learning Objectives.................................................................................................................. 80
Prerequisites ............................................................................................................................ 80
Required Tools for Completing This Module ............................................................................. 80
Associated Data ....................................................................................................................... 80
2D Scatter Plot and Regions of Interest.................................................................................... 80
Supervised and Unsupervised Classification ............................................................................ 83
Terrain Categorization ............................................................................................................ 100
Skills Check ........................................................................................................................... 100
Self Test ................................................................................................................................. 107

Exploring ENVI

79

Regions of Interest and Classification Techniques

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Work with the 2D scatter plot
Understand and create regions of interest (ROIs)
Use ROIs to classify an image
Modify a classification result using the Rule Classifier
Evaluate classification results using statistics and class overlays

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. Also you should know how to
display an image in ENVI and work with the Layer Manager.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

ca_coast.dat A Thematic Mapper Simulator collected from a Daedalus AADS-1268


scanner that flies on an ER-2 aircraft. This scanner simulates the Landsat instrument with a slightly
higher spatial resolution. The image covers a region of the central California coast with 11 spectral
bands ranging from 0.42 to 8.5 m, and 25 m pixels.
SKorea_sub Quickbird scene over South Korea.

2D Scatter Plot and Regions of Interest


Regions of interest (ROIs) are often used as classification training sets and can be generated from numerous
sources: manually from an image using the mouse; from scatter plots; and from vector layers.

Exercise #1: Quick Classification Using Interactive 2D Scatter Plots


You can classify an image if you know the surface materials in certain regions, referred to as training areas,
for a classification. Sufficient information is often not available to help determine appropriate training areas.
However, ENVI provides a 2D scatter plot tool that you can use as a first step in determining appropriate
classification training areas.
ENVIs 2D scatter plot tool allows you to compare not only the relationship between data values in two
bands but also the spatial distribution of pixels in an image. This combined functionality provides a very
simple, two-band, interactive classification of image data.
1. From the ENVI main menu bar, click on the Open folder icon. Navigate to envidata\TMS, and
select ca_coast.dat. Click Open. A color image is displayed. It may be useful to display a
color-infrared (CIR) image to help you discriminate vegetation.
2. Change the contrast stretch by selecting from the stretch pull-down menu. A Linear 1% contrast
stretch works well for this scene.
3. From the ENVI menu, select Display 2D Scatter Plot. The Scatter Plot tool appears displaying
Band 1 versus Band 2. Adjacent bands are often highly correlated because they measure similar
wavelengths. Therefore, using two adjacent bands often produces a scatter plot where the data cloud

80

Exploring ENVI

2D Scatter Plot and Regions of Interest

Regions of Interest and Classification Techniques

resembles a line with a slope of 45 degrees. To avoid this highly correlated scenario, choose two
bands that measure very different wavelengths. For example Bands 1-3 measure reflectance in
visible wavelengths, while Bands 7 and 8 measure reflectance in near-infrared wavelengths.

4. Let the X Band display Band 1 (wavelength of 0.42 micrometers). Click on the Y Band pull-down
list and select Band 8 (0.91 micrometers). The scatter plot automatically scales its axes to maximize
separation in the data.
5. Click and drag a corner of the scatter plot to make it larger. This will help you use more detail in the
scatter plot. Click and drag the mouse in the image display and notice the dancing pixels in the
scatter plot. The highlighted pixels are representative of a 10 x 10 pixel area surrounding the current
cursor location in the Image window. As you move the cursor around the image, notice how the
dancing pixels in the scatter plot are often clustered together.
6. Move the cursor to the scatter plot. Highlight a 10 x 10 pixel area by clicking and dragging the
middle mouse button in the scatter plot. This highlights the pixels in the image that have the
combination of spectral values corresponding to the 10 x 10 pixel area in the scatter plot. As you
click and drag inside the scatter plot window note how different areas of the image are highlighted.
You can change the size of the 10 x 10 pixel area by moving the Patch Size slider or by typing in
the text box after the slider.
7. Click on the Density Slice to view the data distribution and how different areas of the data cloud are
thicker" (warmer colors) or "thinner (cooler colors).
8. If you are not viewing the entire image in the display but you want the scatter plot to show all the
pixels in the image, de-select Viewable Area Only.
You may have noticed that certain areas of the scatter plot correspond to well-defined features in the

Exploring ENVI

81

Regions of Interest and Classification Techniques

2D Scatter Plot and Regions of Interest

image. You can take advantage of this information to interactively define ROIs from the scatter plot.
You can use these ROIs later for classifications.
9. Look for clusters of pixels or arms protruding from the center of the scatter plot. These areas likely
represent particular features on the ground. Click and drag to draw a polygon over a cluster of pixels
then accept the polygon by right-clicking once. Again you will find that unique and pure materials
in the scene always form corners or distinct clusters in the data cloud. You want to avoid drawing
ROIs near the center of the data cloud. The pixels there are likely to contain mixtures of materials.

10. You can change the scatter plot background color by clicking on the Properties icon at the bottom of
the plot. Define three more polygon ROIs using different colors. Select a different color for each
ROI by clicking the Class Functions pull-down list before drawing a new ROI.
11. To delete an ROI, make sure its color is listed under Class Functions and click Clear.
12. When you are finished defining ROIs in the scatter plot, check the box for All Classes and click
Export. If you are offered a choice for Base ROI Visualization Layer, choose the top layer and click
OK. The ROIs will be listed in the Layer Manager.
13. Close the scatter plot by clicking the X button.
14. Right click on one of the ROIs listed in the Layer Manager and select Stats. A dialog will appear
showing you plots of minimum, maximum, mean, and standard deviation values. A table shows you

82

Exploring ENVI

Supervised and Unsupervised Classification

Regions of Interest and Classification Techniques

the same information. You can click on Select Plot or Select Stat to show band histogram values.
Close the ROI Statistics Results dialog.
15. To edit ROIs, right-click on one and select Properties. Click in the ROI Name window and change
the ROI name to signify what material the ROI represents. Rename all your ROIs in this way. If you
want to change the ROI color, click on ROI Color, then select a new color from the drop-down list.
16. Save your ROIs for future use by right-clicking on the Regions of Interest file in the Layer
Manager and selecting Save As .ROI. Click on the folder icon and browse to
C:\ENVI_coursefiles\envidata. Then type in a file name of Ca_coast and click
Open. The .ROI extension will automatically be added. Click OK.

Supervised and Unsupervised Classification


ENVI provides several options for automatically classifying images, using unsupervised and supervised
techniques. These options are available by selecting Classification from the ENVI Toolbox.
Classification algorithms differ in the criteria used for defining decision boundaries. With all classifiers,
ENVI first computes a set of statistics for each region or class. Then, using these statistics and user-defined
thresholds, ENVI retrieves the spectral values for each pixel in the image and determines its placement in
classification space. Often, this involves calculating and evaluating a similarity measure to compare each
pixel to the possible classes. Thresholds are frequently used to determine which pixels are so dissimilar from
all classes that they should be considered unclassified.
ENVIs simplest classification methods are the Unsupervised IsoData and K-Means classifiers, often
referred to as clustering routines. These classifiers do not require previous knowledge about the scene. They
use information from the image to identify spectral clusters, which are interpreted as classes. The IsoData
classifier asks you to specify a range of output classes, then it uses iterative class splitting, merging, and
deleting to determine the final number of classes. The K-Means classifier asks you to specify a number of
output classes. Generally, IsoData and K-Means classify all pixels in the image, but you can specify a
threshold to leave some pixels unclassified.
Supervised classifiers require input of class information before classification. For example, the ROIs defined
in the previous exercise can be used as training data for any supervised classification technique. The
supervised classification methods discussed in this chapter are Parallelepiped, Minimum Distance,
Maximum Likelihood, Mahalanobis Distance, Binary Encoding, and Neural Net.
With the Parallelepiped classifier, ENVI constructs a parallelogram in n-D spectral space (where n
represents the number of bands being used in the classification), wholly enclosing each ROI. ENVI only
assigns pixels that fall into the parallelogram into the class corresponding to the ROI. By leaving the default
parameters in place, this method frequently leaves many pixels unclassified.
The Minimum Distance classifier calculates the distance of each pixel in n-D spectral space from the n-D
means of the ROIs. The pixel is assigned to the class corresponding to the ROI with the closest mean. If the
pixel is beyond a threshold distance from the closest mean, it remains unclassified.
The Maximum Likelihood classifier uses the distribution of data within each ROI to calculate n-D
probability functions for each class. Each pixel is assigned to the class for which the highest probability is
calculated. This classification works best when the data are normally distributed. Again, it is common to
have many pixels remain unclassified with this method.
The Mahalanobis Distance classifier is a direction-sensitive distance classifier. It is similar to Maximum
Likelihood, except that it assumes all class covariances are equal and is therefore a faster method.
The Binary Encoding classifier encodes the pixel and training spectra into zeros and ones for each band,
based on whether each band value falls below or above the mean of the spectrum, respectively. Pixels are

Exploring ENVI

83

Regions of Interest and Classification Techniques

Supervised and Unsupervised Classification

assigned to the class that has the encoded spectrum with the greatest number of bands matching the encoded
pixel spectrum. Some pixels may be unclassified if your specified minimum match threshold is not
exceeded. This classifier is robust in the presence of noisy data.
The Neural Net classifier consists of a network of many simple classification rules, each of which can be
used to differentiate classes. Neural Net adjust the weights used in each classification rule through a series
of iterations in which the current classification of ROI data is compared to the true classes for those data. In
other words, the Neural Net classifier learns from the ROI examples and exhibits some capability for
generalization beyond the ROIs.
The Decision Tree classifier uses a series of binary decisions to place pixels into classes. Each decision
divides the pixels in a set of images into two classes based on an expression. You can divide each new class
into two more classes based on another expression. You can define as many decision nodes as necessary.
The results of the decisions are classes. You can use data from many different sources and files to make a
single Decision Tree classifier.
When entering classification parameters for the above supervised classifiers, you have the option to
designate a single threshold for all classes, a separate threshold for each class, or no threshold. For example,
when performing a Parallelpiped classification, you can specify different widths for each class based on
standard deviation. This allows more control over classes where you have confidence that the training data
are more clearly defined and those that are less distinct.

Exercise #2: Minimum Distance Classification and Rule Classifier


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

Exploring ENVI

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

Exploring ENVI

85

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.

86

Exploring ENVI

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.

Exploring ENVI

87

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.

88

Exploring ENVI

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
homogenous may be adequately characterized with just one ROI. Materials that are more variable
may need several ROIs to define them sufficiently.

Exploring ENVI

89

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.

90

Exploring ENVI

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.

Exploring ENVI

91

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.

Exercise #4: Maximum Likelihood Classification


For this classification you will create training site vectors before starting the classification routine.
1. To create training site vectors, click on File New Vector Layer from then ENVI menu.
2. The Create New Vector Layer dialog appears. Type in soil in the Layer Name field. Then click OK.
3. Draw a few polygon vectors over areas of bare ground. You should try to include areas that
encompass the variability of the class. In the Layer Manager, the icon of a vector layer that has been
edited and not yet saved is stippled.
4. Save the vectors by right clicking on the vector layer in the Layer Manager and selecting Save As.
In the Save As dialog, leave the file name as soil and note that it will be saved as a shapefile. Click
Save. The icon for this layer will no longer be stippled.

92

Exploring ENVI

Supervised and Unsupervised Classification

Regions of Interest and Classification Techniques

5. Click on File New Vector Layer from then ENVI menu.


6. The Create New Vector Layer dialog appears. Type in crops in the Layer Name field. Then click
OK.
7. Draw several polygons over various agricultural fields. Save the changes to this vector layer as you
did to the previous vector layer.
8. Create new vectors for additional classes as you wish. Possible other classes include dark bare
fields, urban materials, ocean, rivers, wetlands, native brush, etc. Remember that you should only
include one material in each class, and also be sure to choose enough training sites to represent the
diversity of each class.
9. When you are finished defining class training sites, click on the Select tool to get out of Vector
Create mode.
10. In the ENVI Toolbox expand the Classification and Supervised Classification folders. Then
double click on Maximum Likelihood Classification. A Classification Input File dialog appears.
11. 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.
12. The Maximum Likelihood Parameters dialog appears. The vectors you created should be listed.
Select the vectors you wish to use. To set a threshold so that some pixels are unclassified, enter a
Probability Threshold value of 0.95. This means that if the highest likelihood calculated for all
classes for a given pixel is less than 0.95, then the pixel will remain unclassified.

Exploring ENVI

93

Regions of Interest and Classification Techniques

Supervised and Unsupervised Classification

13. Click the Preview button. The image that appears can be used to help you evaluate the classes you
have created. Dont worry if the result is not accurate, you will use the Rule Classifier tool to set
class thresholds later.
14. For Output Classification Filename type Ca_coast_maxlike.dat. For Output Rule Filename
type Ca_coast_maxlike_rule.
15. Click OK to run the classification.
16. The classification result will be displayed. To evaluate it right click on the original image in the
Layer Manager and select Display in Portal. After the portal appears, compare it to the
classification result either by using the Transparency slider, or by right clicking in the Portal and
choosing Blend, Flicker, or Swipe. Remember you can move the portal around as well as resize it.

17. Right click in the Portal and choose Close Portal.


18. Uncheck some of your classes to view the underlying image. This is probably a rule image, so
uncheck any rule image listed in the Layer Manager. This should allow you to see the original color
scene below unchecked classes.

19. Next you will improve the classification result by setting thresholds for each class. In the ENVI
Toolbox expand the Post Classification folder and double click on Rule Classifier.

94

Exploring ENVI

Supervised and Unsupervised Classification

Regions of Interest and Classification Techniques

20. In the Rule Image Classifier dialog, select Ca_coast_maxlike_rule and click OK.
21. 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 Maximum Likelihood algorithm evaluates
matches by using a measure of probability, this means that larger pixel values in the rule images
indicate a better match. So, let Classify by default to Maximum Value.
22. 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.
23. 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.
24. In the Rule Image Classifier Tool dialog, click the Hist button for a class. A histogram plot window
for the rule image appears. Again, pixel values in rule images represent how well a particular pixel
matched a class training site. Logical places to put thresholds 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 materials.
25. For the Maximum Likelihood classification good matches are at the right side of the histogram
(higher values). Zoom into the right side of the histogram by placing your cursor in the histogram
and hold the CONTROL key down while you draw a box in the histogram. You cant zoom in
when the cursor is near the edge of the plot, but if you start the zoom box in the plot window, you
can extend it beyond the plot axes. What can also help is using SHIFT click to pan around in the
histogram plot. If you need to zoom back out, right click in the histogram and choose Reset Plot
Range. 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.
26. The figure below shows an example histogram of the ocean class. Because there are a lot of pixels
in the ocean, the class is represented by a large peak. 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, a likely threshold value is -553.

Exploring ENVI

95

Regions of Interest and Classification Techniques

Supervised and Unsupervised Classification

27. 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.
28. Click on the Hist button for each class and determine a good threshold for each. You may need to
rest the histogram by right clicking and selecting Reset Plot Range. Or you can hit the SHIFT key
and pan around the plot. Type your threshold values in to the appropriate Tresh field.
29. When you have finished finding good thresholds for your classes save your new result by clicking
Save To File on the Rule Classifier Tool.
30. In the Output Rule Classification Filename dialog, type in Ca_coast_max_class.dat and
click OK.
31. 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_max_class.dat and select Load Grayscale.

96

Exploring ENVI

Supervised and Unsupervised Classification

Regions of Interest and Classification Techniques

32. Close the Rule Image Classifier Tool and the Data Manager.
33. 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
right click in the portal and use Blend, Flicker, or Swipe to compare your result to the input data set.
34. When you are finished with the evaluation, right in the portal and choose Close Portal.

35. An optional step is to clean up your result using Clump and Sieve. To use them, double click on
Clump Classes and Sieve Classes in the Post Classification folder in the ENVI Toolbox. This will
reduce the number of vectors produced in the next step.

Exploring ENVI

97

Regions of Interest and Classification Techniques

Supervised and Unsupervised Classification

36. 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_max_class.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_max_class.evf and click OK.
37. To display the vector files, open up Windows Explorer, browse to your output folder and drag the
vector files into the ENVI display. The RTV (raster to vector) layers will be overlain on top of the
displayed image. The vector editing tools will be available if you want to make edits.

Exercise #5: Class Statistics


1. To generate statistics for the classification result from the previous exercise, double click on Class
Statistics under the Classification Post Classification folder in the ENVI Toolbox.
2. In the Classification Input File dialog, select Ca_coast_max_class.dat and click OK.
3. In the Statistics Input File dialog select Ca_coast.dat and then click on Spectral Subset,
deselect the thermal band (Band 11) and click OK. You did not use Band 11 in the classification.
Click OK to close the Statistics Input File dialog.
4. In the Class Selection dialog, select all classes and exclude Unclassified. Click OK.
5. In the Compute Statistics Parameters dialog, keep Basic Stats checked and also check Histograms.
Click OK.
6. In the Class Statistics Results dialog that appears, the mean spectra for all classes are shown in the
plot window. Below that the Class Distribution Summary lists the number of pixels and percentage
of the image assigned to each class.
7. Below the Class Distribution Summary is a statistics table for one of your classes. You can choose
which class to show stats for by selecting from the Stats for pull-down menu at the top of the
dialog.
8. From the Select Plot pull-down menu select Histogram: All Bands. These histograms show the
values for a particular class in all bands. Change to another class by selecting a different class from
the Stats for pull-down menu.
9. To see the histogram for all classes in a specific band click on Select PlotHistogram for all
ClassesBand 1.
10. Right click in the histogram plot and choose Plot Key. If the plaot names in the key are too long to
read, right click in the histogram plot and choose Edit Plot Parameters. In the Plot Parameters
dialog, increase the value for Right Margin until you can read the class names. Close the Plot
Parameters dialog.
11. Click on Select PlotHistogram for all ClassesBand 2. These histograms will be added to the
plot. To view histograms for one class at a time, click on Clear Plot before you choose the next
class.
12. When you are finished examining the statistics, close the Class Statistics Results dialog.

98

Exploring ENVI

Supervised and Unsupervised Classification

Exploring ENVI

Regions of Interest and Classification Techniques

99

Regions of Interest and Classification Techniques

Terrain Categorization

13. Right click on View at the top of the Layer Manager and choose Remove All Layers.

Terrain Categorization
The Terrain Categorization (TERCAT) tool creates an output product in which pixels with similar spectral
properties are clumped into classes. These classes may be either user-defined, or automatically generated by
the classification algorithm. The TERCAT tool provides all of the standard ENVI classification algorithms,
plus an additional algorithm called Winner Takes All.

Exercise #6: Supervised Terrain Classification (TERCAT)


1. From the ENVI menu bar, click the Open folder. Navigate to the envidata\Quickbird
directory, select the SKorea_sub image and click Open. The file will be displayed.
2. Adjust the contrast of the image. A Linear 2% or 5% contrast stretch works well for this scene.
3. Click on the Zoom To Full Extent icon.
4. Start the SPEAR Tools by expanding SPEAR in the ENVI Toolbox, then double click on SPEAR
TERCAT.

5. The TERCAT wizard displays the File Selection panel. Click Select Input File, choose the file
SKorea_sub, and then click OK. The input image to SPEAR should be a multispectral file in any
format readable by ENVI. If the wavelengths are not listed in the image header, a series of Select
Band dialogs appear. SPEAR allows the user to process only a portion of the scene, using the Select
Subset option.
By default, the SPEAR output files are saved to the same directory and use the same rootname as
the input file, minus any extension. Change the output directory by clicking the Select Output Root
Name button. Browse to the envidata\output directory and click Open. Keep the checkbox
next to the Show informational dialogs between steps checked. Click Next. The Atmospheric

100

Exploring ENVI

Terrain Categorization

Regions of Interest and Classification Techniques

Correction panel appears.


6. Atmospheric Correction is available within many of the SPEAR tools. For most spectral processing
applications, working with atmospherically-corrected data produces the most accurate results.
Atmospheric correction methods available in SPEAR include: Dark Object Subtraction; Flat Field
Calibration; Internal Average Relative Reflectance, Log Residuals, and Empirical Line Calibration.
The Dark Object Subtraction routine is appropriate for multispectral data. Select Show Advanced
Options. Within the Dark Object Subtraction Parameters panel, change the search area to Entire
scene, and uncheck the Use ignore data value. Click Next.
7. In the Method Selection panel that appears you will select the classification methods to use.
Unsupervised methods do not require training data to create a TERCAT, and the resulting classes
will not be labeled. Supervised methods require you to train the algorithms by creating regions of
interest (ROIs) that include representative pixels of the desired classes. Check only the Maximum
Likelihood, Spectral Angle Mapper, and Minimum Distance algorithms for this exercise. Also
select Winner Takes All (TERCAT).
8. Click Next. A 3-window display group appears showing the scattered light-corrected SKorea_sub
image appears. Click OK after reading the important message about selecting ROIs.

9. The ROI Tool also opened up with the image. Make sure the ROI_Type is set to Polygon and click
the Image radio button to draw polygons in the main display window. Move the red box in the
Scroll window to find an area that contains urban materials, forests, rivers, and crop fields (Figure
3). Click to draw polygon vertices over an urban area. One right click will close the polygon and a
diamond-shaped handle will appear that will allow you to reposition the polygon if you wish. If you
arent satisfied with the polygon at this point (with the diamond handle visible), a middle click will
erase it. A second right click will close and fill the polygon. Click twice in the ROI Name block for
this red region and change the name to urban. Click on New Region and next draw a polygon for a
forest ROI. Repeat the process to define training sites for the river and crop fields. Edit the ROI

Exploring ENVI

101

Regions of Interest and Classification Techniques

Terrain Categorization

names appropriately. If you want to change the color of an ROI, right click in the Color box and
select a color from the pull-down list.
Note: It is important that you do not mix the materials you are trying to classify in the same ROI.

ROIs drawn in the main display window.

10. Click on New Region in the ROI Tool. Change the name of this ROI to roads. Click ROI_Type
and select either Polyline or Point. Click on the Zoom radio button so that you can draw in it for
detailed work.
11. Re-position the main display window and the Zoom window so that sections of road are visible in
the Zoom window. Draw a polyline and/or place points along sections of road. Try to avoid mixing
other materials in the roads ROI.

102

Exploring ENVI

Terrain Categorization

Regions of Interest and Classification Techniques

12. When you are finished drawing ROIS, click the Off radio button on the ROI Tool.
13. Return to the TERCAT panel and Click Next and then OK when the ROI Selection panel appears.
14. Each TERCAT method has its own set of advanced parameters that you can adjust. To view the
advanced parameters, click Show Advanced Options, and then click on the tab for each algorithm
to view the possible parameters. In most cases, using the default values produces satisfactory
results. Select Output rule images?. You can use these to modify class thresholds later. Click Next
to move run the classifications.
15. After processing is complete, two dynamically linked display groups appear: the natural color
composite is the reference image (on the left) and the Maximum Likelihood classification results
(on the right). Add an additional display to the group by selecting the Spectral Angle Mapper
from the Results Display #2 drop-down list. Roam around in the displays to compare results. Left
click in a display to see another display. To cycle through each display, hold the left mouse button
down in one display while you click with the middle mouse button. Black pixels are unclassified.

Exploring ENVI

103

Regions of Interest and Classification Techniques

Terrain Categorization

16. Right click in any of the display windows to select Cursor Location/Value. Move the mouse over
an image to see the names of the classes assigned for any given pixel.
17. After comparing the Maximum Likelihood and Spectral Angle Mapper results, replace one of them
with the Minimum Distance result.
Which result maps the forests better? The river? Urban areas?
18. In the TERCAT Examine Results panel, select Winner Takes All (TERCAT) from the Results
Display #1 drop-down list.
Does this image show fairly good results? In the case of a tie between algorithms, the dominant
class of the neighboring pixels is used to classify the pixel in question.
After inspection of the results it may be that you wish to change something and re-run the
classifications. One thing you may see is that some holding ponds are classified as roads. If you
have time you can rectify this by clicking the Prev button to go back and perhaps add a training site
for the holding ponds.
19. In addition to the TERCAT product, ENVI creates a Winner Takes All (Probability) image. This
image indicates the level of confidence for each pixel's classification, as determined by the number
of classification methods that correctly classified the pixel. Load the Winner Takes All
(Probability) map using the Results Display #2 drop-down list and query the pixels with the
Cursor Location/Value tool. The user should carefully examine areas with the darkest pixels (lowest
probability, here 0.33) and consider revising the training ROIs. You might be able to improve the
results by adding more polygons for a particular class to better encompass its variability.

104

Exploring ENVI

Terrain Categorization

Regions of Interest and Classification Techniques

20. A number of post-classification processing techniques available in ENVI are available directly from
the SPEAR GUI. These methods may be used to clean the TERCAT results by removing
spurious pixels that may not be significant for the terrain classification. You can also generate class
statistics from your TERCAT such as means spectra, area covered by each class, etc. In this step
you will select the TERCAT(s) that the desired operation should be performed on from the
TERCATs to process list. Then you select the class(es) that the operation should be performed on
and the desired operation from the Processing to perform drop-down list. Depending on the method
chosen, parameters may appear in the area immediately below the Processing to perform drop-down
list. Select the Majority Analysis process for the Maximum Likelihood result. De-select
Unclassified from the Classes to process list. Click Go after making the appropriate selections.

21. When processing is complete, click OK in the Information dialog. Load the Maximum Likelihood
(MAJORITY) result into Results Display #2 and compare the results.

Maximum Likelihood result on the left and Maximum Likelihood (MAJORITY) on the right.

22. Select Class Statistics from the Processing to perform drop-down list and click GO. To view the
statistics for any class, select that class from the Stats for drop-down list.

Exploring ENVI

105

Regions of Interest and Classification Techniques

Terrain Categorization

23. When you are finished examining results, click Next in the Examine Results panel, then click Finish to
exit the wizard. Close the Statistics dialog if it is still open.
24. If you have time, try the Rule Classifier on some of the rule images. Because smaller values are better
matches with the Minimum Distance and Spectral Angle Mapper classifiers, the Classify By toggle should
be set to Minimum Value. For Maximum Likelihood, in which larger values are better matches, it should
be set to Maximum Value.

106

Exploring ENVI

Skills Check

Regions of Interest and Classification Techniques

Skills Check
At this point you should:
Know how to work with the 2D scatter plot
perform several types of classification
Know how to set thresholds using the Rule Classifier
Know how to get class statistics

Self Test
1. How do you choose what bands to use in the 2D scatter plot?
2. What tool is good to use for determining good thresholds for individual classes?

Exploring ENVI

107

Chapter 7:

Principal Components
Analysis

Learning Objectives................................................................................................................ 110


Prerequisites .......................................................................................................................... 110
Required Tools for Completing This Module ........................................................................... 110
Associated Data ..................................................................................................................... 110
Introduction ............................................................................................................................ 110
Skills Check ........................................................................................................................... 115
Self Test ................................................................................................................................. 115

Exploring ENVI

109

Principal Components Analysis

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Perform a Principal Component transformation
Geo link multi-view images
View PCA statistics

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. Also you should know how to
display an image in ENVI and work with the Layer Manager.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

2010_09_1_Pan_Sharpened_Refl An ALI scene over Boulder, Colorado. This data set


has nine channels.

Introduction
Principal components analysis (PCA) is used in many branches of science, particularly for analyzing data
with large dimensionality. This analysis is useful for enhancing information content, segregating signal from
noise, and reducing the dimensionality of data sets.
PCA is a mathematical technique that transforms a multivariate data set into a new coordinate system. The
axes, or principal components (PCs), of the new coordinate system are specific linear combinations of the
original data set and are uncorrelated. The first PC is in the direction of the greatest variance in the data set.
The second PC is orthogonal to the first and explains the second greatest variance in the data set, and so
forth.
The eigenvectors and eigenvalues are typically computed from the covariance matrix. Because the PC
transform maximizes the data variance in the first few PC bands, these bands usually contain most of the
coherent image information and can be used to isolate common features in the data. Often, higher-order PC
images contain rare features and/or noise.

Exercise #1: Principal Components Rotation


This exercise uses nine channel ALI data from Boulder, Colorado collected after a significant fire.
1. From the ENVI main menu bar, click on the Open folder icon. Navigate to envidata\ALI, and
select 2010_09_1_Pan_Sharpened_Refl. Click Open. A color image is displayed. If a
color-infrared (CIR) image is not displayed, use the Data Manger to load it. This will help you
discriminate vegetation.
2. Adjust the contrast stretch if necessary by selecting from the stretch pull-down menu. A Linear 1%
or 2% contrast stretch works well for this scene.
3. Change the zoom factor so that you see most of the image.
4. In the ENVI Toolbox, expand the Transform and PCA Rotation folders then double click on

110

Exploring ENVI

Introduction

Principal Components Analysis

Forward PCA Rotation New Statistics and Rotate. A Principal Components Input File dialog
appears.
5. Select 2010_09_1_Pan_Sharpened_Refl. Before you click OK, click on Mask Options
Build Mask.
6. In the Mask Definition dialog, select Options Import Data Range. Then select
2010_09_1_Pan_Sharpened_Refl and click OK.
7. In the Input for Data Range Mask dialog, type in a value of 0 for Data Max Value. Leave the Data
Min Value blank. This will include all negative values in the mask. Select Mask pixel if ANY
band matches range. Click OK.
8. In the Mask Definition dialog, select Options Selected Areas Off. With this option all pixels
that have negative or zero values in the input data will have values of 0 in the mask. Consequently,
those masked pixels will not be used in the PCA transform.
9. For output filename type 2010_09_1_mask. Click OK to build the mask. Then click OK in the
file selection dialog.
10. The Forward PC Rotation Parameters dialog appears. You will generate statistics from the data and
save them to a file. In the Output Stats Filename field, enter ALI_pca.sta.
Using existing statistics saves a lot of time when running the PCA. To calculate statistics on an
image before running the PCA, select from the ENVI main menu bar.
11. In the Enter Output Filename field, enter ALI_PC.dat.
12. Leave the default values for all other fields. Click OK. When processing is complete, a PC
Eigenvalues plot appears and PC 1 will be displayed.

13. In the PC Eigenvalues plot, the nine new bands (principal components) are specified along the x

Exploring ENVI

111

Principal Components Analysis

Introduction

axis. The y axis represents eigenvalues, or the amount of variance that is described by each principal
component. You can see that the first three to four components of the PCA contain nearly all of the
variance (signal) in the scene. From this eigenvalue plot, you would expect that the last couple of
PC bands do not contain much signal that you can distinguish from the noise. Close the PC
Eigenvalues plot.
14. In the main ENVI menu click Views 3x3 Views. You should see PC Band 1 displayed in the first
(upper left) window. You will place the other PC bands in the other views.
15. Open up the Data Manager. Make sure the second view is selected (highlighted) then right click on
PC Band 2 and choose Load Grayscale.
16. Select the third view (upper right), then in the Data Manager right click on PC Band 3 and choose
Load Grayscale. Repeat this process for the other six PC bands.
17. Click Views Geo Link Views. In the Geo Link Views dialog that appears, click Link All. You
will see the chain link icon in the bottom left corner of each view. The anchor icon in the first view
is colored. This means the other views will adjust to match this view. You can choose another view
to be the lead view by clicking the anchor icon in another view.

18. Click OK in the Geo Link Views dialog. The views will be linked but the new views may have a
different zoom level. The new views may have a zoom factor of 100%. Click on a view to
determine the zoom level. Click on the first view and then choose 100% from the zoom level dropdown menu. If a view is blank, refresh the display by clicking with the middle mouse button in a
display to access the pan tool, then drag that cursor a short distance.
Other ways to move around in the views are to use the Fly tool, or click on one of the Overview
layers in the Layer Manager and click and drag the view box in the Overview window around.
19. Images of the first few PC bands are sharp and spatially coherent, while the last few PC bands
primarily contain noise, making features difficult to find.

112

Exploring ENVI

Introduction

Principal Components Analysis

20. After you have inspected the PC Bands click on Views One View.
21. If the Data Manager is not visible, open it up. Load an RGB composite of the first three PC bands
by selecting them and then clicking Load Data. You can also use the Band Selection panel to do
this.
What features do you see clearly in this color composite?

Exercise #2: Viewing PCA Statistics


1. From the ENVI Toolbox, expand the Statistics folder and double click on View Statistics File. An
Enter Statistics Filename dialog appears.
2. Navigate to your output directory, and select ALI_pca.sta. Click Open. A statistics report
dialog appears showing plot and text information from the statistics file.
3. The plot displays the minimum, maximum, mean, and standard deviation for the original image
bands. Click Select Plot to view the standard deviation or eigenvalue plot.

Exploring ENVI

113

Principal Components Analysis

Introduction

4. The lower half of the dialog contains text statistics: mean, maximum, minimum, standard deviation,
correlation, and covariance matrices. And at the bottom, the eigenvector matrix. To generate images
of the covariance, correlation and eigenvector matrices, select File Save Current Covariance to
Image from the statistics report dialog menu bar. The output images will be placed in memory and
listed in the Data Manager. They will be very small (9 x 9 pixels for this data set).
5. Of particular interest after a PC transformation are the eigenvalues and eigenvectors. As mentioned
previously, the eigenvalues indicate the amount of variance described by each PC axis. The
eigenvectors correspond to the PC axes and the eigenvector matrix shows the relative contributions
of each original image band to the PC bands.

114

Exploring ENVI

Skills Check

Principal Components Analysis

6. When you are finished open up the Data Manager, and click on the Close All Files icon. Also close
the statistics dialog.

Skills Check
At this point you should:
Know how to perform a Principal Component Analysis
Know how to view a statistics file
Know how to load multiple image views and geo link them

Self Test
1. What is the purpose of running a PCA?
2. Which PC bands contain the most signal?
3. Which PC bands might contain the signal for rare materials?

Exploring ENVI

115

Chapter 8:

Spectral Libraries and


Hyperspectral Processing
Tools
Learning Objectives................................................................................................................ 118
Prerequisites .......................................................................................................................... 118
Required Tools for Completing This Module ........................................................................... 118
Associated Data ..................................................................................................................... 118
Introduction ............................................................................................................................ 118
The Sequential Maximum Angle Convex Cone (SMACC) ...................................................... 118
Working with Spectral Libraries .............................................................................................. 123
Spectral Angle Mapper (SAM) Classification .......................................................................... 124
Skills Check ........................................................................................................................... 131
Self Test ................................................................................................................................. 131

Exploring ENVI

117

Spectral Libraries and Hyperspectral Processing Tools

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Extract and examine spectral profiles from hyperspectral data
Learn how and why to use spectral Libraries
Compare data-derived spectra to known library spectra
Use the Spectral Angle Mapper (SAM) classifier

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. Also you should know how to
display an image in ENVI and work with the Layer Manager.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

cup95_at.dat Airborne Visible/Infrared Imaging Spectrometer (AVIRIS) data from


Cuprite, Nevada, USA, collected in 1995 and spectrally subsetted to 50 channels from 2.0-2.4 m.
jpl1sli.dat - JPL Mineral Spectral Library, which has approximately 300 mineral spectra
measured over a wavelength range from 0.4 m to 2.5 m in 826 bands.

Introduction
This section of the course introduces you to ENVIs spectral analysis tools. While many of these tools were
originally designed for use with hyperspectral data, they often work quite well for multispectral data. See
ENVI Help for full documentation on spectral analysis tools.
Unfortunately, there is not enough time in this course to cover all of these topics. However, there is an
additional in-depth four-day course, Spectral Analysis with ENVI, which concentrates on these advanced
spectral analysis tools.
Data exploration techniques such as extracting and collecting image spectra, or comparing image spectra to
known references, are important steps in image interpretation and information extraction. ENVI provides a
suite of tools specially designed to help work with image and library spectra.
While learning about spectral analysis tools in the following exercises, you will often see the term
endmembers. These are spectrally unique materials that make up a scene. With each similarity classifier,
you can use endmember spectra obtained from relatively pure pixels in the data, or from field or laboratory
measurements. ENVI provides several unique tools designed to help extract endmember spectra from
images. You will use spectra extracted from the data, as well as laboratory spectra, as input into the Spectral
Angle Mapper (SAM) algorithm to classify the Cuprite image.

Sequential Maximum Angle Convex Cone (SMACC)


The Sequential Maximum Angle Convex Cone (SMACC) is a fast method of finding and mapping
abundances of endmembers in a data set. The natural variability in individual endmember spectra is used to
help make the abundance images more accurate. Constraints may be applied to the routine. These include
limiting abundance coefficients to positive values and summing abundances of materials for each pixel to
one (100%) or less.

118

Exploring ENVI

Sequential Maximum Angle Convex Cone (SMACC) Spectral Libraries and Hyperspectral Processing Tools

Exercise #1: Using SMACC to Extract Endmembers


1. From the ENVI main menu bar, click on the Open folder icon. Navigate to envidata\cup95av,
and select cup95_at.dat. Click Open. A grayscale image is displayed because this data set does
not contain visible or near infrared wavelengths. It only contains SWIR wavelengths.
2. Change the zoom factor to fill the display with the image.
3. In the ENVI Toolbox, expand the Spectral folder then double click on SMAAC Endmember
Extraction.
4. From the Select Input File dialog, select cup95_at.dat and click OK.
5. In the SMAAC Endmember Extraction Parameters dialog change the default value for Number of
Endmembers to 10.
6. Click the Sum to Unity or Less radio button.
7. Select Coalesce Redundant Endmembers, and accept the default SAM Coalesce Value.
8. Under Endmember Location ROIs, enter an output filename of cup95_smacc.roi.
9. Under Abundance Image, enter an output filename of cup95_smacc_abundance.
10. Under Select Output Spectral Library, enter an output filename of cup95_smacc.sli.
11. Click OK to run SMACC.

Two plot windows appear one over the other. One of the plots shows the SMACC spectral library
containing the signatures from all the pixels it flagged as endmembers.

Exploring ENVI

119

Spectral Libraries and Hyperspectral Processing Tools Sequential Maximum Angle Convex Cone (SMACC)

The SMACC Relative Error plot window shows that the relative error started to converge at two
extracted endmembers. Although you specified a value of 10, the remaining endmembers were
coalesced into similar spectra to form the resulting six endmembers.

12. Close the SMACC Relative Error plot window, but keep the Endmembers plot window open.

120

Exploring ENVI

Sequential Maximum Angle Convex Cone (SMACC) Spectral Libraries and Hyperspectral Processing Tools
13. The SMACC algorithm also outputs abundance images for each endmember including Shadow
(depending on which constraint you select). The first abundance image is displayed. If this image is
offset, click on the Zoom To Full Extent icon.
14. Examine the Shadow abundance image, then right click on the View layer in the Layer Manager and
select Remove All Layers.
15. Next you will examine each abundance image by loading them into separate views. Select Views
3x3 Views from the ENVI menu.
16. Because there are six actual abundance images, right click one of the views in the Layer Manager
and select Remove View. Repeat this two more times to get the number of views down to six.
17. Open up the Data Manager. Select the first view by clicking in it, then right click on Endmember 1
Abundance and choose Load Grayscale.
18. Select the second view, then in the Data Manager right click on Endmember 2 Abundance and
choose Load Grayscale. Repeat this process for the other four abundance bands.
19. Click on the Cursor Value icon and move the cursor over the abundance images. Data values within
a given image indicate fractional abundances of that endmember in each pixel. For example, a data
value of 0.491435 indicates that nearly 50% of that pixel contains the material represented by the
extracted endmember.
At this point the endmembers are unknown. You could use ENVIs Spectral Analyst to identify
each endmember (see ENVI Help for details).
20. When you are finished, close the Cursor Value dialog. Then click on the Views One View.
21. To load a color composite in the display, expand cup95_at.dat in the Data Manager if
necessary, then click on Band 185 to load as red, Band 193 as green, and Band 197 as blue.
22. Remove the remaining abundance image, and click on the Zoom To Full Extent icon.
23. Close the Data Manager but still leave the Endmembers plot window open.

Exercise #2: Examining Image Spectra


1. From the ENVI menu bar, click on Display Spectral Profile. An empty Spectral Profile plot
window appears. In the color display, click on a various colored pixels to view their spectra.
Do you see any spectra that resemble the ones collected by SMACC?
2. Collect a few spectra by pressing the SHIFT key and clicking on a various colored pixels.
3. To zoom to a specific area of the plot, press the SHIFT key and the cursor will turn into a
magnifying glass, then click and drag to create a box that encloses the zoom area. SHIFT click will
allow you to pan in plot window. To reset to the original zoom range, right click in the plot and
select Reset Plot Range.
4. Click on a spectrum to select it, then drag your cursor along it. X and y values for the spectrum will
be shown in the bottom right corner of the plot window and update as you move the cursor.
5. Click on the black arrowhead on the right side of the Spectral Profile window to expand it to show
the legend. You can delete a spectrum by right clicking on it in either the plot window or the legend
and choosing Remove Selected Spectrum. In the future if you want to save displayed spectra, click
on the floppy disk icon above the legend and then type in an output file name. This saves the spectra
as a spectral library.
6. There are several icons below the plot window. Going from left to right, the first one sends the plot

Exploring ENVI

121

Spectral Libraries and Hyperspectral Processing Tools Sequential Maximum Angle Convex Cone (SMACC)
image to a printer, the second one saves the plot image to as an image file; several formats are
possible. Click on the third icon, a Properties dialog appears for the currently selected spectrum.
This allows you to change the spectrum name, its color, and line style, and also use a symbol. Close
the Properties dialog.
7. The next icon resets the axis range. Click on the Edit icon which is next. This allows you to send a
spectrum forward or back in the plot, and also cut, copy, and paste spectra. The legend is not
updated for any of these options.
8. Click on the last icon, Annotation. This allows you to annotate the plot window. Select an Arrow
for annotation and click and drag in the plot window to place it. With the arrow selected, click on
the Properties icon below. You can use this to edit the arrows properties. With the arrow still
selected click on the Edit icon and select Cut. This is the process you can use to place, edit, and
remove any annotation.
9. Click on the Annotation icon again. Then select Legend. This places another legend within the plot
window. Its placement there ensures that if you save the plot as an image file, you will see a legend.
Click and drag the legend around to position it. If you dont want the plot legend overlaying spectra
you can position it to the side. First drag the legend to the side of the window, then click in the plot
itself to select it and you should see blue dots at the corners and the center points of the axes. Click
on the blue dot on the right side and move the side of the plot so that the legend does not overlap it.
You can adjust the aspect ratio of the entire Spectral Profile window so the plot doesnt look
squashed. After modifications to the plot, you can output it to an image if you want to use it in a
report.

10. Right click in the plot window and select Remove All. You could collect new spectra at this point.
Close the Spectral Profile window. But still keep the Endmembers plot window open for the next
section.

122

Exploring ENVI

Working with Spectral Libraries

Spectral Libraries and Hyperspectral Processing Tools

Working with Spectral Libraries


You can use libraries of field or laboratory spectral signatures to visually and analytically identify materials
in an image. ENVI includes several public-domain spectral libraries and tools to work with them. ENVI
provides spectral libraries developed at the Jet Propulsion Laboratory (JPL) for three different grain sizes of
approximately 160 pure minerals from 0.4 m to 2.5 m. ENVI also provides the U.S. Geological Survey
(USGS) spectral library with nearly 500 spectra of well-characterized minerals and a few vegetation spectra,
from a range of 0.4 m to 2.5 m. ENVI spectral libraries are stored in ENVIs image format, with each line
of the image corresponding to an individual spectrum and each sample of the image corresponding to a
spectral measurement at a specific wavelength (see ENVI Help for more information).

Exercise #3: Open a Spectral Library and Compare with Image Spectra
1. The Endmembers plot window should still open. In this exercise you will compare spectra in that
plot to library spectra.
2. In the ENVI menu, click Display Spectral Library Viewer. The Spectral Library Viewer dialog
appears. The libraries that come with ENVI are listed in the left hand panel. Normally you would
use the Spectral Analyst tool to automatically compare image spectra with library spectra. However,
in this exercise you will simply load library spectra in to a plot and compare visually.
3. Expand the JPL_lib jpl1.sli library listings.
4. Click on ALUNITE SO-4A to display that spectrum. Note the wavelength range is 0.4 to 2.5
micrometers. The data range for the image spectra is limited to 2.0 to 2.5. Zoom in to the Spectral
Library Plot by SHIFT clicking to draw a box over the alunite spectrum from about 2.0 to 2.5
micrometers.
5. Note that there is a large absorption feature in the alunite spectrum around 2.16 micrometers and a
smaller absorption feature near 2.32 micrometers.
Is there a spectrum in the Endmembers plot that looks like this?
If so, change the name of the endmember spectrum by first expanding the right hand panel so you
see the legend, select the spectrum that looks similar to alunite, then click on the Properties icon.
Change the label in the Name field to alunite. Close and expand the legend panel to see the name
change.
6. In the Spectral Library Viewer dialog, click on CALCITE C-3E to display that spectrum.
Is there a spectrum in the Endmembers plot that looks like this?
If so, change the name of that endmember spectrum by selecting the spectrum, then in the
Properties panel change the label in the Name field to calcite. Close and expand the legend panel
to see the name change.
7. In the Spectral Library Viewer dialog, click on KAOLINITE WELL ORDERED PS-1A to
display that spectrum.
Is there a spectrum in the Endmembers plot that looks like this?
If so, change the name of that endmember spectrum by selecting the spectrum, then in the
Properties panel change the label in the Name field to kaolinite. Close and expand the legend
panel to see the name change.

Exploring ENVI

123

Spectral Libraries and Hyperspectral Processing Tools

Spectral Angle Mapper (SAM) Classification

8. In the Spectral Library Plots dialog, right click and select Remove All.
9. Under the jpl1.sli library listing click on BUDDINGTONITE FELDS TS-11A then ILLITE PS11A to display those spectra. You will use the three data spectra and these two spectral library
spectra in the next exercise.
10. It is very important not to use the same color for more than one class. If one of the library spectra
has the same color as one of the image spectra, change one or the other. Select the spectrum you
want to change then click on the Properties icon and change its color.
11. Leave both spectral plots open for the next exercise.

Spectral Angle Mapper (SAM) Classification


Spectral Angle Mapper (SAM) is an automated method for comparing image spectra to endmember or
library spectra. If you are matching to a spectral library, you need to convert the image data to apparent
reflectance to match the library. The SAM algorithm determines the similarity between two spectra by
calculating the spectral angle between them, treating them as unit vectors in spectral space with
dimensionality equal to the number of bands.
The simplest way to understand this classifier is to consider a hypothetical image pixel spectrum from a
two-band image and a library spectrum. The two spectra can be represented in a 2D scatter plot as two
points (figure below). A vector from the origin through each point describes the position of each material
under all possible illumination conditions.

124

Exploring ENVI

Spectral Angle Mapper (SAM) Classification

Spectral Libraries and Hyperspectral Processing Tools

The color of the material is defined by the direction of the unit vectors. SAM uses only the direction of the
vectors and not the vector lengths. For this reason, SAM is insensitive to differing amounts of illumination.
The SAM classifier generalizes this geometric interpretation in n-D space, where n is the number of bands
in the image. For each endmember or library spectrum selected during the analysis, the n-D spectral angle
(in radians) is determined for every pixel in the input image. A spectral angle image is output for every
endmember or library spectrum you select. These spectral angle images are referred to as rule images. The
smaller the angle, the more similar the data spectrum is to the endmember or library spectrum. Therefore,
when viewing the resulting SAM rule images, darker pixels indicate better matches.
SAM also outputs a classified image that assigns each pixel to a class. The classification chooses the
endmember or library spectrum that makes the smallest spectral angle with each pixel in the input image.

Exercise #4: SAM Classification


1. In the ENVI Toolbox, expand Classification Supervised Classification. Then double click on
Spectral Angle Mapper Classification. The Classification Input File dialog appears.
2. Select cup95_at.dat but do not click OK yet! SAM and other spectral processing algorithms
work best if you limit the spectral range to that which has distinctive reflectance properties for the
material you want to map. So you will spectrally subset the input data in the next step.
3. In the Classification Input File dialog, click Spectral Subset. A File Spectral Subset dialog appears.
4. All bands are selected by default. Click Clear. Next, you will select bands that encompass
characteristic absorption features. Click Band 179 (2.0609 m), hold down the mouse button and
drag to t Band 214 (2.4096 m). 36 bands should be selected. Click OK. Confirm that 36 of 50
bands are selected.
5. Click OK in the Classification Input File dialog. The Endmember Collection:SAM dialog appears.
This dialog is a generic ENVI dialog that is used for most all of the classification and mapping
routines that require endmember spectra to be specified. Using the Algorithm menu, you can apply
any classification technique supported by ENVI to the selected image with these reference spectra.
6. In the Endmember Collection:SAM dialog click Import from Plot Windows.
7. In the Import from Plot Windows dialog, CONTROL click to select the spectra you named (alunite,
calcite, and kaolinite) and also BUDDINGTONITE FELDS TS-11A and ILLITE PS-11A. Then

Exploring ENVI

125

Spectral Libraries and Hyperspectral Processing Tools

Spectral Angle Mapper (SAM) Classification

click OK.

8. Click on the Plot button. You should see the three image-derived spectra viewed over the
wavelength you specified for SAM. You may not see the library spectra because they have a
different y scale.

126

Exploring ENVI

Spectral Angle Mapper (SAM) Classification

Spectral Libraries and Hyperspectral Processing Tools

9. Close the Endmember Collection Spectra plot.


10. In the Endmember Collection dialog note that you can also gather spectra from an ASCII file, an
ASD file, ROI/EVF files, or a statistics file.
11. Click Apply in the Endmember Collection:SAM dialog. The Spectral Angle Mapper Parameters
dialog appears.
12. Type cupSAM.dat in the Enter Output Filename field.
13. Type cupSAMrule in the Enter Output Rule Filename field.
14. Keep the default value of 0.10 for Maximum Angle (radians). This angle defines the threshold
used by the SAM classifier. Any image pixel whose SAM angle is larger than the threshold for any
of the selected spectra will remain unclassified. Thus, the smaller the maximum angle, the more
stringent the classification becomes. You can also choose Multiple Values to set different thresholds
for each spectrum youre matching to. However, it is best to use the Rule Classifier tool for this
after the classification is run.
15. Click OK to start the classification. When finished, the SAM classification image and rule images
are listed in the Data Manager. The classification result is automatically displayed. The colors of the
classification image correspond to the colors of the spectra you used to match.
16. To compare the classification result to the input scene click on the View Flicker icon in the ENVI
menu bar. Remember that accessing Blend, Flicker, and Swipe from the menu creates a portal that
covers the entire display. Move your cursor to the top of the display to see the portal controls. To
close the portal either click on the x at the top of the portal, or right click in the portal and select
Close View Portal.
17. Another way to help you evaluate the result is to make the classification partially transparent by
selecting it in the Layer Manager and then adjusting the Transparency slider.

Exploring ENVI

127

Spectral Libraries and Hyperspectral Processing Tools

Spectral Angle Mapper (SAM) Classification

18. Inspect the classification result to determine which class covers the most area. Then in the Layer
Manager, turn this class off by un-checking it.

19. In the Data Manager, right click on the rule image for one of the classes still displayed and select
Load Grayscale.
20. To place the rule image below the classification, right click on it in the Layer Manager and select
Order Send Backwards.
21. Comparing spectra from various pixels in the image to the reference spectra is a good way to
evaluate matches. Placing a rule image over the input scene helps you determine at what rule image
value the transition is made from having the reflectance feature of interest to not having it. In the
ENVI menu, select Display Spectral Profile.
22. In the ENVI menu, click on the Cursor Value icon. Remember that for SAM, lower values in the
rule image means a better match. Click on a class overlaying a dark area in the rule image to see the
spectrum for that pixel and also note the rule image value. Do you see the characteristic absorption
feature for that class in the spectrum for that pixel? The figure below does show the distinctive
kaolinite absorption feature for a pixel with a rule image value of 0.069.

128

Exploring ENVI

Spectral Angle Mapper (SAM) Classification

Spectral Libraries and Hyperspectral Processing Tools

23. Click on other pixels that are brighter in the rule image to try to determine a threshold at which you
no longer see the absorption feature for that class. Your Endmembers and Spectral Library plots
should still be open to help you make that evaluation.
Optional: Use the above method to find suitable thresholds for each class. Remember to load the
appropriate rule image for each class. It is good practice to start with classes that appear to match
too many pixels. After finding thresholds for your classes, re-run SAM. When the Spectral Angle
Mapper Parameters dialog appears, select Multiple Values. The Assign Maximum Angle (radians)
dialog appears. Type in the rule image values that you determined were good thresholds. Then click
OK. You can quickly judge the new angles by clicking Preview.
24. Close the Cursor Value dialog and the Spectral Profile window. Besides looking at spectra to see at
what rule image value they transition from having to not having the reflectance feature of interest,
another way to determine appropriate thresholds is by looking at the histogram of rule images as
discussed in an earlier chapter. You will do this next.
25. In the ENVI Toolbox expand the Post Classification folder and double click on Rule Classifier.
26. In the Rule Image Classifier dialog, select cupSAMrule and click OK.
27. 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 Spectral Angle 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.
28. 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.
29. 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.
30. 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 histogram shows the distribution (x-axis) and frequency (yaxis) of pixel angle values (in radians) from the class endmember.
Things you should consider are how abundant and variable the classes are. Materials that are rare in

Exploring ENVI

129

Spectral Libraries and Hyperspectral Processing Tools

Spectral Angle Mapper (SAM) Classification

the scene will be found in the tail of the histogram. Materials that are abundant will be represented
by a peak.
31. Place your cursor in the histogram and hold the CONTROL 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.
32. 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 between 0.08
and 0.11.

33. 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.
34. 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.
35. When you have finished finding good thresholds for all classes save your new result by clicking
Save To File on the Rule Classifier Tool.
36. In the Output Rule Classification Filename dialog, type in cupSAM_class.dat and click OK.
37. 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 cupSAM_class.dat and select Load Grayscale.
38. When finished examining the SAM results, click on the Close All Files icon in the Data Manager.
Then close remaining dialogs and plot windows.

130

Exploring ENVI

Skills Check

Spectral Libraries and Hyperspectral Processing Tools

Skills Check
At this point, you should feel comfortable:
Extracting a Z-Profile from an image
Viewing Spectral Libraries
Working with plot windows
Using the Spectral Angle Mapper classification tool
Using the Rule Classifier to modify classification results

Self Test
1. How do you collect multiple spectra in a plot window?
2. When working with SAM rule images in the Rule Classifier do you toggle classify by to Minimum
Value or Maximum Value?

Exploring ENVI

131

Chapter 9:

Extending ENVI
Learning Objectives................................................................................................................ 134
Prerequisites .......................................................................................................................... 134
Required Tools for Completing This Module ........................................................................... 134
Associated Data ..................................................................................................................... 134
Introduction ............................................................................................................................ 134
Band and Spectral Math ......................................................................................................... 135
Tips for Writing Expressions ................................................................................................... 136
Batch Processing in ENVI ...................................................................................................... 148
Library Routines ..................................................................................................................... 151
ENVI Extensions .................................................................................................................... 155
Skills Check ........................................................................................................................... 161
Self Test ................................................................................................................................. 161

Exploring ENVI

133

Extending ENVI

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Use Band Math to calculate a difference image
Use Band Math to create a composite image
Use Band Math to run a custom normalized difference index.
Use Spectral Math to create a mixed spectrum and remove background spectral information.
Learn how to start and use ENVI from the IDL command line
Edit and execute an ENVI batch program
Add extensions to ENVI

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. Also you should know how to
display an image in ENVI r and how to manipulate an image displayed in ENVI.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

avhrr.dat NOAA AVHRR scene with 1.1 km spatial resolution, collected around 2:00 AM
local time in mid-April 1997
new_zeal_wv2_sub.dat - WorldView 2 scene over New Zealand.
manmade2.sli - Spectral library from Johns Hopkins
qb_boulder_msi Quickbird scene from Boulder, Colorado
JasperRidge98av_flaash_refl.dat AVIRIS hyperspectral data from Jasper Ridge,
California
Boulder-ETM.dat Landsat 7 Enhanced Thematic Mapper data over Boulder, Colorado
urban_geo_sub.dat- subset of Boulder Quickbird scene

Introduction
One of ENVIs best features is that its functionality is not limited to what you find on the menu. ENVI
developers designed the software so that it can be easily customized. Common ENVI extensions include
user Band Math and Spectral Math functions, custom spatial, spectral, or region of interest (ROI)
processing, user functions, custom file input routines, batch processing, and other report and plotting tools.
Many ENVI library routines are available to help you write custom routines while maintaining the same
look-and-feel as ENVI.
There are three basic methods for extending ENVI:
1) Band Math and Spectral Math. You can enter most Band Math and Spectral Math expressions
directly in ENVIs Band Math and Spectral Math dialogs, respectively. Or, you can write user
functions to handle the data input, output, and user interfaces.
2) Headless (Batch Mode) ENVI. Performing a linear sequence of ENVI processing tasks in a noninteractive manner is called batching. You can write a batch mode routine (an IDL program) and
call it from the ENVI menu system to perform the tasks, or you can start batch mode from the IDL
command line. In Windows you can bring up the IDL workbench by clicking the IDL icon listed
with ENVI on the Windows start bar.
134

Exploring ENVI

Band and Spectral Math

Extending ENVI

3) Extensions. Extensions are programs you write in IDL, C, Fortran, or another high-level language,
that perform a specific ENVI processing task. You can integrate them into ENVI and run them from
ENVIs extensions toolbox.
Because ENVI is written entirely in the Interactive Data Language (IDL), you will use IDL syntax to create
extensions. You can use Band Math and Spectral Math successfully with only a limited knowledge of IDL.
The band math and spectral math exercises in this chapter assume no experience with IDL, whereas some
understanding of IDL will be helpful with the more advanced topics.

Band and Spectral Math


ENVIs Band Math and Spectral Math functions are particularly useful for quickly and flexibly
manipulating image data. To use these tools, enter a mathematical expression and assign its variables to
image bands or spectra. Band Math and Spectral Math operate with only three basic limitations:
Your expression must return a 2D image array (for Band Math) or a 1D vector (for Spectral Math).
The image bands (or spectra) assigned to each variable in the expression must have the same
dimensions. In other words, all of the bands must have the same number of samples and lines, or all
of the spectra must have the same number of bands.
All variables must be named B1, B2, B3 or S1, S2, S3 and each of these variables must be
assigned to one band or spectrum.
Because of their broad nature, these tools are often useful for quickly analyzing or combining different data
sources. For example, Band Math can be useful for calculating a difference image for change detection, or
for computing custom indices.

Exercise #1: Difference Image


1. From the ENVI main menu bar, select File Open Navigate to envidata\extend and open
the file avhrr.dat.
2. Open the Data Manager by selecting its icon, or activating it from the File menu. Right click on
the SST Image band and select Load Grayscale.
3. Create a second view by clicking on Views Create New View to split the display. Make sure the
second view is active, then right click on AVHRR Band 5 (12.0000) in the Data Manager and click
Load Grayscale.
4. Select Display Cursor Value and move the cursor around an image and look at the data values
for the two displays.
This image is a NOAA AVHRR scene with 1.1 km pixel size, collected around 2:00 AM local time
in mid-April 1997. The scene covers a section of the East Coast of the USA from approximately
New York City to the North Carolina border. It extends out into the Atlantic Ocean about 1,000 km.
You may recognize the Chesapeake Bay region along the left edge of the image.
The first View contains sea surface temperature (SST) data in degrees Celsius, calculated from three
thermal AVHRR bands. The second View contains SST data calibrated in Kelvin, calculated from
one thermal band (at 12 m). Note the spiral feature centered near image location (1030,1030). This
is a warm eddy in the Gulf Stream current.
These two images represent separate SST estimates in the scene. One algorithm is well-suited for
SST estimates, and the other is more general. To examine the differences between these two
algorithms, you have to create a difference image and also account for the different temperature
units in the two images. You can easily accomplish this with Band Math.

Exploring ENVI

135

Extending ENVI

Tips for Writing Expressions

5. Select Views One View.


6. From the ENVI Toolbox, begin typing Band Math or select Band Ratio Band Math. A Band
Math dialog appears.
7. In the Enter an expression field, type the following:
b1 - (b2 - 273.16)
8. Click OK. The Variables to Bands Pairings dialog appears.
9. The variable B1 [undefined] is selected by default. Map this variable to a specific band by
selecting SST Image in the Available Bands List in the Variables to Bands Pairings dialog. The
Variables used in expression window shows this assignment.
Note: You can also apply a Band Math variable to an entire file instead of a single band by clicking
Map Variable to Input File. This can be useful if, for example, you want to subtract one image band
from all of the bands in a multi-band image.
10. Select B2 [undefined], then click AVHRR Band 5 to associate that band to the variable.
11. The bottom of the Variables to Bands Pairings dialog now provides options to output to file or
memory. File is already selected by default. Enter an output filename of
sst_thermal_diff.dat.
12. Click OK. The Band Math result appears in the Data Manager and it may also be displayed (if it is
not displayed, right click on the Band Math result in the Data Manager and select Load Grayscale).
Looking at the difference image, you should immediately see where the largest discrepancies occur
in the two temperature estimates.
Can you identify the features selected by the difference image? These are areas where the ocean
surface is obstructed by clouds.
13. Right click on the View item in the Layer Manager and select Remove all Layers.
Any Band Math expressions you enter during an ENVI session are available throughout the session, and
they appear in the Previous Band Math Expressions list of the Band Math dialog. You can save expressions
that you use regularly to a file, so that you do not have to re-enter them in the Band Math dialog each time
you need them. Give the current expression list a filename with an .exp extension and click Save in the
Band Math dialog. Then, you can restore the expressions later when you need them.

Tips for Writing Expressions


In the first exercise, you produced useful results using a relatively simple mathematical expression.
However, in some cases, you may require more complicated expressions. Depending on your familiarity
with IDL, it may take some practice to find the best way to write a single expression to accomplish your
goals. ENVI actually performs a quick test of Band Math expressions to see if they are valid, by using a 5 x
5 array of random data values ranging from 0 to 255. If you get an error when entering an expression and
you are unsure of the problem, you may find it helpful to think of your expression in the following context:
IDL> result = expression
Note that data types are often a cause for concern. Two types of problems will be encountered regularly
when performing band math integer overflow and type specific division. Bring up the IDL workbench by
clicking on its icon in the Windows start bar, then type in the following IDL expressions:
ENVI> print, 120B + 230B
94

136

Exploring ENVI

Tips for Writing Expressions

Extending ENVI

ENVI> print, 120 / 230


0

In the first example, adding 120 to 230 results should give us 350. Instead, we get 94. Why is this the case?
Because these two variables are of type byte (the B in the expression is a declaration of byte variable type),
they are only allotted enough memory to store 256 unique values 0 through 255. When an expression
takes them beyond this range, the data type overflows and in so doing, wraps around to the lower end of its
value. You can think about this as a cars odometer flipping over from 999999 to 000000 when driven one
million miles. We get 94 from 350 256 (the number of unique values it overflows before flipping). So, 94
values after the data type has wrapped around.
In the second case, we can see that IDL defaults to floor division for integer types (floor division is just a
fancy way of saying division that preserves whole numbers the type of division with remainders you
probably did in grade school). This ensures that an expression of integers always creates integers an
important feature of an optimized array-based mathematical language, but one that can throw new users off
when they try to perform a normalized index on image data of integer values.
We can fix both of these problems by using conversion functions in IDL:
ENVI> print, long(120B) + 230B
350
ENVI> print, float(120) / 230
0.521739

In the first fix, weve promoted our byte data type to a long integer making it so that our range of
allowable values is much larger, allowing values from 2,147,483,648 to 2,147,483,647! In the second fix,
weve converted our data to a type that allows decimals a floating point value. We also could have
converted the first example to floating point to solve the overflow problem:
ENVI> print, float(120B) + 230B
350.000

As such, if you d rather not worry about remembering all the details of which data types are which for band
math expressions, using float() can be a good all-purpose fix. There are a few areas where this breaks down
(e.g. converting really large integers with lots of degrees of precision, or adding very small and very large
values together), but for band math calculations, it doesnt come up often.
Note: It is only necessary to convert one component of a simple expression. For more complex expressions,
you will want to convert at least a single component of each sub expression. This has been done incorrectly
in the first example below and correctly in the second example.
ENVI> print, float(120B) + 230B/120B
121.000
ENVI> print, float(120B) + 230B/float(120B)
121.917

If your expression works at the IDL command line as the expression portion of a statement, then it should
generally work in Band Math or Spectral Math. In this context, you should see that you cannot use control
statements like FOR loops or IF...THEN statements in a single Band Math expression. However, by taking
advantage of IDLs powerful array operators, you can often accomplish the same tasks.
For example, if you wanted to assign all pixel values less than 30 to the smallest pixel value in an image,
you do not need to loop through every pixel in the image and test its value, nor do you want to use IDLs
WHERE function. Instead, you could use the following Band Math expression:

Exploring ENVI

137

Extending ENVI

Tips for Writing Expressions

MIN(b1)*(b1 le 30) + (b1)*(b1 gt 30)


This expression works because the array operator statements (b1 le 30) and (b1 gt 30) are evaluated
first as an array of the same size as b1 filled with ones (for true) and zeros (for false). So, in the first part of
the expression, the minimum value in b1 is multiplied by an array of the same size as b1 that contains ones
(where b1 is less than or equal to a pixel value of 30) and zeros everywhere else. In the next exercise, you
will use this approach to make a composite image that represents temperature based on two different bands
of the AVHRR file.

Exercise #2: Composite Image


1. In the Data Manager, right click on SST image and select Load Grayscale.
2. Click Views Two Horizontal Views to open a second display. Select the second View, then in
the Data Manager, right click on AVHRR Band 5 and select Load Grayscale.
3. Link the two display groups by clicking Views Geo Link Views. Click Link All then click OK.
4. Select Cursor Value from the menu then move your cursor over the large, dark feature near image
location (1180, 1220) in file coordinates (displayed as File: in the Cursor Value dialog).
As you learned in Exercise 1, the estimated temperatures in the areas where the ocean is obscured
by clouds differ markedly from those derived from the calibrated thermal band. The data values in
the SST image are about -48 degrees Celsius. This is clearly not the correct ocean temperature.
The algorithm used to calculate SST does not accurately calculate cloud-top temperatures. For
cloudy areas, a thermal band should better estimate SST. Using Band Math, you can selectively
substitute the data values from one of the thermal bands into the SST band, producing a composite
image of temperature. As an initial test, you will use a threshold value of 0 in the SST image for the
substitution criterion.
5. From the ENVI Toolbox, select Band Ratio Band Math.
6. Type the following in the Enter an expression field:
(b1)*(b1 GT 0.0) + (b2 - 273.16)*(b1 LE 0.0)
7. Click OK. The Variables to Bands Pairings dialog appears.
8. The variable B1 [undefined] is selected by default. Select SST Image in the Available
Bands List of the Variables to Bands Pairings dialog.
9. Select B2 [undefined], then select AVHRR Band 5 in the Available Bands List of the
Variables to Bands Pairings dialog.
10. Enter an output filename of sst_thermal_composite.dat.
11. Click OK. The composite image appears in the Data Manager and will also load into whichever
ever view is active (you can make a view active clicking on it in ENVI).
12. Move your cursor over the composite image. Note that data values in ocean areas unobscured by
clouds are nearly identical to those from the SST image in Display #1. However, data values in
cloudy regions are the same as those from the thermal band (AVHRR band 5). If your assumption is
correct, the SST algorithm had significantly overestimated the cloud-top temperatures.
13. Click Views One View. Then right click on the View item in the Layer Manager and select
Remove. Close the Cursor Value dialog.

138

Exploring ENVI

Tips for Writing Expressions

Extending ENVI

Normalized Difference Images


A common type of index used (especially for moderate resolution multispectral data) is the Normalized
Difference Index. NDVI (Normalized Difference Vegetation Index) incorporates the Red and Near-Infrared
bands, and is the most commonly known of these indices. As a result, it is available by default in many GIS
and remote sensing software packages. Several others, such as the NDWI (Water Index), NBR (Normalized
Burn Ratio) and NDBI (Built-up Index) have been proposed and used.
When Digital Globes Worldview-2 was launched and began operations, the narrower bands allowed for
new and alternative indices to those that were developed for Landsat MSS and TM sensors. In the next
exercise, we will use the ability of band math to enter an expression once and re-use it to generate several
Normalized Difference Images.
The formula for a generic Normalized Difference Image is as follows:
NDI = (Band1 Band2) (Band1 + Band2)
So a normalized burn ratio index with Landsat would be:
NBR = (TM4 - TM 7) (TM4 + TM 7)
And the standard NDVI image could be expressed as:
NDVI = (NIR - RED) (NIR + RED)
Therefore, we can represent this entire class of indices with the following band math expression:
(b1 - b2) / (b1 + b2)
Taking into account the data type concerns expressed in the Tips for Writing Expressions section, we can
account for multiple data types by changing the expression to:
(float(b1)-b2)/(float(b1)+b2)
The spectra available in Worldview-2 (with Spectral Response) are (after Wolf 2010):

Wolf (2010) recommends the use of the following indices for WV-2 data:
= NDWI (Water)
= NDVI (Vegetation)
= NDSI (Soil)

Exploring ENVI

139

Extending ENVI

Tips for Writing Expressions

= NHFD (Non-homogenous Feature Index)

Just a note in summary, the Bands typically available in WV-2 scenes and their corresponding wavelengths
are:
Coastal
Band 1
427.000
Blue
Band 2
478.300
Green
Band 3
545.700
Yellow
Band 4
607.700
Red
Band 5
658.800
Red Edge
Band 6
724.100
NIR1
Band 7
832.900
NIR2
Band 8
949.300

Exercise #3: Generating a set of Normalized Difference Images from WV-2


1. In ENVI, select File Open then navigate to envidata\extend, select
new_zeal_wv2_sub.dat and click Open.
2. Click on the Zoom To Full Extent icon.
3. Go to the text box underneath the Toolbox dialog and begin typing Band Math. Alternatively,
navigate to Band Ratio Band Math. Double click the Band Math tool to start it.
4. Enter the formula for normalized difference indices described in the section previous.
(float(b1)-b2)/(float(b1)+b2)
5. When the formula is entered, click OK.
6. The first index well calculate is Wolfs alternative NDWI. Map B1 to the Coastal Band by clicking
B1 and then clicking the first band (wavelength 427.00 micrometers). Then click B2 followed by
the NIR band 2 the last band in our image.
7. For the output navigate to your envidata\enviout directory and name the file
new_zeal_wv2_ndwi.dat, then click OK.
8. The result will be displayed. Adjust the transparency slider to investigate the relationship between
the index and the original image. There are several false positives in shadowy areas and on asphalt,
but as water is a low reflectance feature, these are expected from an index.
9. Double click on Band Math again. Notice that your previous expression is still stored:

140

Exploring ENVI

Tips for Writing Expressions

Extending ENVI

Click on the expression. Save this expression by clicking Save. Save the file as norm_diff_ind.exp
to your enviout directory then click OK. Now, you can still restore this same expression in a later
session.
10. Click the expression, then click OK. Well repeat step 4 from above for the three other indices by
running band math three more times, mapping the variables in this way:
B1

B2

NDVI (vegetation)

Band 8 (949.3)

Band 5 (658.8)

NSDI (soils)

Band 3 (545.0)

Band 4 (607.0)

NHFD (man-made features)

Band 6 (724.1)

Band 1 (427.0)

11. After finishing generating the bands, create four new views by clicking Views 2x2 Views.
12. Open the Data Manager.
13. Load each of the generated indices into one of the views by clicking on a View in the Layer
Manager and then right clicking on an index in the Data Manager and selecting Load Grayscale.
Then click the Zoom To Full Extent icon for each. If you want, load the
new_zeal_wv2_cal.dat original image into each of the views and experiment with
transparency in each of the images.
14. Close all but one of the Views and remove the images from the Layer Manager.

Spectral Math
Spectral math is used to customize spectra for use as endmembers in classification, spectral mixture
analysis, and target detection. Spectra can be imported from either a pixel in a multi-band image (plotted in
the Z-profile), a spectral library, an ASCII file, or an IDL variable. To perform Spectral Math, you will
need to load each spectrum into a plot window prior to running the Spectral Math tool.
As with Band Math, you can save Spectral Math expressions to a file for future use, assign variables to files
instead of individual spectra, and execute previously compiled IDL routines by calling them from the

Exploring ENVI

141

Extending ENVI

Tips for Writing Expressions

Spectral Math dialog. In this example, we will mix spectra by combining several known endmembers.

Exercise #4: Using Spectral Math to Create Mixed Spectra


1. In ENVI, select Display Spectral Library Viewer. Expand the jhu_lib folder. This folder
contains spectral libraries from John Hopkins University.

2. Open the spectral library file manmade2.sli to see a list of spectra in the library.

3. Click on the library entries entitled Aluminum Metal (0384UUUALM), Olive Green Gloss Paint
(Paints 0386UUUPNT), and Oxidized Galvinized Steel Metal (Metal 0526UUUSTLa). These
spectra will now be displayed in the Spectral Library Viewer. These plots are laboratory-measured

142

Exploring ENVI

Tips for Writing Expressions

Extending ENVI

reflectance spectra. The x-axis is wavelength and the y-axis is percent reflectance. Using spectral
math, we will create a weighted average or mixed pixel spectrum comprised of these three
materials.

4. Locate the Spectral Math tool by typing Spectral Math into the Toolbox tool location dialog.
Then, double click Spectral Math to launch the tool. In the Enter an expression text box, enter the
expression:
s1 * 0.4 + s2*0.3 + s3*0.3
Note: Regardless of which spectra you will select, you always have to represent the spectra with the
variables s1, s2, etc. in spectral maths expression dialog.
5. Click OK. You will be prompted to pair variables to spectra.

Exploring ENVI

143

Extending ENVI

Tips for Writing Expressions

6. Match S1 to Aluminum Metal, S2 to Olive Green Gloss Paint, and S3 to Oxidized Galvanized
Steel Metal. To do this, first click the Variable to be used from the Variables used in expression:
sub-dialog, then click the matching spectrum from the Available Spectra list.
7. You can toggle the Output Result to New Window or leave it to output to the Same Window.
Same window will allow you to compare the resulting spectrum to its component spectra. Select
New Window, then click OK.
8. The resulting spectrum will be loaded into a new window. Its name is currently the same as the
expression we used to create it. Click the expand arrow in the dialog to view the legend. Double
click on the title of the new plot, and click in the Name field, delete the current name, and enter
green structure. You may also change the line style, thickness, or color of the plot if you so
choose. Click the X to close the dialog when you are finished.

144

Exploring ENVI

Tips for Writing Expressions

Extending ENVI

9. The finished spectrum can now be added to a spectral library or used as input for a spectral mapping
routine. Close the Spectral Library Viewer and the spectral plot.

Exercise #5: Perform Simple Linear Subtraction to Remove Background


1. Open qb_boulder_msi from the ENVI installation location (C:\Program
Files\Exelis\ENVI50\data).
2. Open a Spectral Profile by selecting Display Spectral Profile from the menu.
3. Navigate to the center of the image, near the large reservoir. Zoom into the bright building and
click on a dark pixel in the shadow of the building (be very precise with the mouse click).

Exploring ENVI

145

Extending ENVI

Tips for Writing Expressions

4. The spectrum will be loaded into the Spectral Profile dialog. Click on the right side of the dialog to
open the legend. The pixel coordinates of the selected spectrum is its current title.

5. Now, SHIFT click and select a pixel from the bright building.
6. The spectral profile for the selected area will be shown in the Spectral Profile dialog as well, again
containing pixel coordinates in its title.

146

Exploring ENVI

Tips for Writing Expressions

Extending ENVI

7. While making sure to keep the Spectral Profile dialog open, run the Spectral Math tool. You will
enter in a new expression: s1 s2. Click OK.

8. Now map the variables s1 and s2 to the two spectra you selected from the image. The bright
impervious surface should be mapped to s1 and the dark shadow should be mapped to s2. When

Exploring ENVI

147

Extending ENVI

Batch Processing in ENVI

these spectra have been matched to their variables, click OK.

9. This resulting spectrum is a basic linear approximation of the signal from the chosen bright
impervious pixel that is not accounted for by the basic background signal in the image.
Note: This is similar to how the scattered-light correction method dark subtraction functions,
except that it applies this subtraction over the entire scene.
10. To more easily compare the spectra, expand the legend of the new plot and then drag the label for
the spectral math result into the legend of the first plot.
11. Close all plots and remove all images from the display.

Batch Processing in ENVI


Performing a linear sequence of ENVI processing tasks in a non-interactive manner is called batching
ENVI. When this is performed while ENVIs GUI is not present, then we are using ENVI in headless
mode. Processes can be batched both with and without ENVIs GUI being present. Batching routines use
ENVI_DOIT library routines to run different processes. To see the full list, consult the help document:
Alphabetic List of ENVI Classic Library Routines. The library routines that end in
DOIT are processes that can be batched with ENVI_DOIT. Some examples are CLASS_RULE_DOIT,
DARK_SUB_DOIT, ENVI_FILTER_DOIT, and MNF_DOIT.

Using ENVIs IDL Command Line


If you have an ENVI+IDL license, when you start ENVI all of the ENVI library routines and save files are
automatically restored. When ENVI is open, you do not have to initiate batch mode in the concurrent IDL
session. You can also use the IDL session to automate tasks in ENVI or perform unrelated IDL operations.
To get access to your current ENVI session as an object, type the following into the console:
IDL> e = envi(/current)

148

Exploring ENVI

Batch Processing in ENVI

Extending ENVI

You can now open rasters or manipulate views using the envi object [e.g. newRaster =
e.openRaster(some_file)]. This can be a convenient way to work, although there are a few things
to take into consideration.
If an IDL procedure you are running at the command line produces a new image band, you can directly
enter this new data by opening it, creating a layer from it, and adding it to the view (more on how this is
done is included later). However, if the IDL procedure crashes, you will also have crashed the concurrent
ENVI session. Also, ENVI may change the scope of your IDL session so that you do not have access to all
the routines normally available at the main program level. When this occurs, you will receive several
unexplained errors until you type retall into the command line to return to the main level of the program.
There are also a few routines that operate differently when ENVIs GUI is present as opposed to when
ENVI is being run in headless mode.
For large volume batch processing, we recommend using headless mode. This will help you avoid any GUI
based errors or unexpected behavior while ENVI is batching processes.

Running ENVI in Headless Mode


Running ENVI headless is no different than working in an ordinary IDL session, except that ENVI library
routines may be used. To get access to ENVI in headless mode, change the focus to your IDL command
line and type:
IDL> e = envi(/headless)

This will restore ENVI library routines and allow you to access various methods off of the envi object. You
can run routines that make use of ENVIs library without its GUI from any IDL program or from the IDL
command line. There are a number of scenarios for which this is appropriate:

You are primarily working in IDL, but occasionally need to use routines that exist only in the ENVI
library.
You want to develop applications that use ENVI library routines but do not make use of ENVIs
GUI.
You need to perform a large amount of ENVI processing without any user interaction (or at least
none with ENVIs interface).

Example Batch Code


Below is a simple batch example that makes use of ENVI 5.0 library routines. This example can be used as
a template for other batch processes.
pro batch_envi_veg_ind
compile_opt idl2, logical_predicate
; Start ENVI headless
e = envi(/headless)
in_file = 'C:\Data\jasper_ridge\JasperRidge98av_flaash_refl.dat'
out_file = 'C:\ Data\scratch\jasper_ridge_veg_ind2.dat'
; Open the file, get back a Raster object.
jasper_ridge = e.OpenRaster(in_file)
; Calculate several vegetation indices
envi_doit, 'envi_veg_index_doit', $
fid=ENVIRasterToFID(jasper_ridge), $

Exploring ENVI

149

Extending ENVI

Batch Processing in ENVI


out_name=out_file

; Exit batch mode and end the program.


e.close
end

Note that there are only a few important steps that must be followed. First, ENVI must be started in
headless mode (e = envi(/headless)). Second, input and output file paths must be provided, and the
input file must be opened (here using e.OpenRaster(in_file)). Third, the ENVI_DOIT routine has to
be called, making use of properties that can be gotten from the raster object. Finally, ENVI is closed if this
is the last process that will be batched (e.close).
Next you will run this program from the IDL workbench. The steps to run a batch program for the exercises
in this section are:
[1] Open the file from the IDL workbench.
[2] Edit any of the parameters you wish to change, including hard-coded directory paths if present.
[3] With the file active in the editor, click Run.

Exercise #6: Run a simple batch program.


Normally you will run batch programs on multiple files. This example has just one file.
1. Typically when running in batch mode you will start a new session of IDL. You can open and run a
batch program in the current ENVI+IDL session. However, if something causes ENVI to crash, you
will also exit IDL. If you start a new IDL session with the current session of ENVI+IDL running
you will need to specify a different directory for the additional IDL Workspace. Start a new session
of IDL by clicking the Windows Start button then browse and select it from All Programs. If you
have ENVI+IDL still running you will be prompted to open a different directory for the new IDL
Workspace.
2. From the IDL menu select File Open or click on the Open folder icon from the menu bar.

3. Navigate to the envidata\extend\src directory and open batch_envi_veg_ind.pro.


The program will be loaded into the IDL workbench.
4. Note that the two variables in_file and out_file are hard coded to point to two files on the
file system. Verify that the input file exists on your operating system at the location specified by
in_file and that you have write permissions to write to the location specified by out_file. You may
need to change the file path for both of these files to point to your extend directory.
in_file = 'C:\envidata\extend\JasperRidge98av_flaash_refl.dat'
out_file = 'C:\envidata\enviout\jasper_ridge_veg_ind2.dat'

Note: The above location will only match some systems. You can test to see if the input file exists
by using the IDL command line in the workbench, e.g.:
print, file_test('C:\envidata\extend\JasperRidge98av_flaash_refl.dat')

This will return a 1 if the path is correct and the file exists and a 0 if the path is not correct or the file
does not exist.

150

Exploring ENVI

Library Routines

Extending ENVI

5. Verifying that batch_envi_veg_ind.pro is the active file in the editor, click the Run icon.
This will both compile and run the program.

6. Restart ENVI by typing the following in the IDL Console.


IDL> e = envi()
7. When ENVI starts, click File Open then navigate to the location specified by the out_file
variable and select jasper_ridge_veg_ind2.dat. One of the products from the processing will
be displayed.
8. Open up the Data Manager and view other vegetation indices. After a product is displayed you may
want to right click on its listing in the Layer Manager and select Change Color Table then
selecting a specific color table to apply. You can also use Raster Color Slices by right clicking on a
product in the Data Manager and selecting Load Raster Color Slices.
9. When you are finished inspecting the results click the Close All Files button in the Data Manager.

Library Routines
Library routines are IDL-based functions and procedures that you call from an IDL or ENVI command line
that encompass nearly all of the functionality in ENVI. ENVI has a combination of object-based and
procedure-based library routines that reflect its development history. Most of the functionality in ENVI has
a corresponding library routine. e.OpenRaster(), for example, is similar to opening a file using File
Open. MATH_DOIT lets you perform band math on an image, just like running Band Math from the
Toolbox.

Common Keywords for ENVI_DOIT


The idealized example above uses ENVI_VEG_INDEX_DOIT a DOIT which does not require too many
keywords to be set. Most ENVI_DOIT routines, however, require that other parameters be set. Below is a
guideline to several common keywords which must be set by DOIT routines.
FID
FID tells ENVI which open file it needs to process. FID stands for File ID and is a long-integer scalar
(single value) that is greater than 0. An invalid FID has a value of -1. The FID is provided as a named
variable by one of several ENVI routines used to open or select a file. You can get a FID back from
ENVI_OPEN_FILE, or by using the ENVIRasterToFID() function on an ENVIRaster object.
DIMS
DIMS tells ENVI_DOIT which part of the file to process. The dimensions keyword is a five-element
array of long integers that defines the spatial subset (of a file or array) to use for processing. Almost every
time you specify the keyword FID, you must also specify the spatial subset of the file to use (even if the
entire file, with no spatial subsetting, is to be processed).
POS
POS tells ENVI which bands to use. Use this keyword to specify an array of band positions, indicating the
band numbers on which to perform the operation. To use the second and third band if a 6 band image, POS
would look like [1, 2]. To use every band in an image, set pos to LINDGEN(NUMBER_OF_BANDS).

Exploring ENVI

151

Extending ENVI

Library Routines

IN_MEMORY
IN_MEMORY tells ENVI whether to create the output in memory or on the file system. This keyword is
set on: (/in_memory) to specify that output should be stored in memory only (e.g. no file will be created). If
you do not set IN_MEMORY, usually you need to set OUT_NAME.
OUT_NAME
OUT_NAME tells ENVI the name of the file to create on the disk to store the results of the process. Use
this keyword to specify a string with the output filename for the resulting data. If IN_MEMORY is set, you
do not need to set OUT_NAME.
OUT_BNAME
Use this keyword to specify a string array of output band names. For example, if using MATH_DOIT to
calculate a custom index, you could specify the result as [NDBR].
R_FID
Use R_FID when you need to get the file ID of the image created by an ENVI process to perform more
processing on the image. The resulting value of the variable set to R_FID can be used to run another ENVI
Routine or to return results with ENVI_FILE_QUERY, just as any other FID.

Exercise #7: Open and run several complex batch programs.


1. If you still have the previous IDL and ENVI session open, go to the IDL workbench and after the
ENVI prompt type:
ENVI> e = envi(/current)
ENVI> e.close
This will close ENVI. Because you started this session as just IDL, closing ENVI will not close
IDL.
2. From the IDL workbench, select File Open or click on the Open icon from the file
manipulation menu bar:

3. Navigate to your extend\src directory and examine the available files. In addition to
batch_envi_veg_ind.pro from the previous exercise there are several other batch examples.
These files contain several types of ENVI_DOIT routines, so looking through them should give you
some basic familiarity with how different keywords are called and used. In addition, a few of them
contain ways to search for and run operations on multiple files or to accept input from the user prior
to initiating the batch. Select the file batch_envi_enh_lee.pro and click Open.
4. The batch code for running the enhanced lee filter in batch_envi_enh_lee.pro is similar to
our simple example from the previous exercise. There are, however, a few areas of code worth
pointing out:
; Get the dims information from the file.
envi_file_query, ENVIRasterToFID(img), dims=dims
; Run Enhanced Lee Filter in batch mode.
envi_doit, 'adapt_filt_doit', $

152

Exploring ENVI

Library Routines

Extending ENVI
pos=lindgen(img.nbands), $
dims=dims, $
fid=ENVIRasterToFID(img), $
method=6, $ ; Enhanced Lee
kx=5,$
cu=0.52, $
cmax=1.73, $
damp=0.0, $
out_name=out_file

In this case, we are running an ENVI process that requires several more parameters, including the
standard keywords POS and DIMS. The METHOD, KX, CU, CMAX, and DAMP keywords are all
explained in the help for ADAPT_FILT_DOIT. These correspond to parameters you would see
when running the tool from ENVIs Toolbox (Filter Enhanced Filter).
To set dims, we use the older routine, ENVI_FILE_QUERY. ENVI_FILE_QUERY accepts a FID,
rather than a raster object, so we use ENVIRasterToFID to get a FID from our ENVIRaster object
IMG. Similarly, we use the NBANDS property of our ENVIRaster to generate our POS array.
The result of this operation for an 8-band image will be [0,1,2,3,4,5,6,7] which will tell ENVI to use
every band in the image.
Optional: If you are not sure what a tool or batch program is doing, check to see which DOIT routine
is being used, then search for it in the Toolbox. You may need to check the help for that particular
DOIT routine. Open and run the tool and try lining up parameters in the tool versus the ones in the
DOIT. There will not always be a one-to-one correspondence (sometimes extra things are exposed in
the GUI, sometimes in the API), but you will be able to get a good feel for how to set the parameters
programmatically by exploring the GUI tools.
5. Change the hard coded input and output file paths as necessary. Then click the Run button to
compile and run batch_envi_enh_lee_rq.pro. This batch program is similar to the previous
example, except that it makes use of a convenience routine not included with the ENVI default.
This program is ENVIRasterQuery, an object interface to get keywords and parameter settings
after querying a file. By default, all the settings of ENVIRasterQuery match those of the input
file. Therefore, it should be used when you intend to run the process on the entire file, rather than a
subset.
6. In the following lines, we can see how ENVIRasterQuery is used:
; Get a Query object to access the raster's properties
img_info = ENVIRasterQuery(img)
; Run Enhanced Lee Filter in batch mode.
envi_doit, 'adapt_filt_doit', $
pos=img_info.pos, $ ; Standard Keyword POS
dims=img_info.dims, $ ; Standard Keyword DIMS
fid=img_info.fid, $ ; Standard Keyword FID
method=6, $ ; Enhanced Lee
kx=5,$ ; Kernel size
cu=0.52, $ ; Homogenous Area Cutoff
cmax=1.73, $ ; Heterogenous Area Cutoff
damp=1.0, $ ; Dampening coefficient
out_name=out_file ; Output file

Because we used the raster query object, now instead of deriving all of the standard keywords from
an input parameter, we can assign them by calling each needed keyword by name from our query
object. So for pos, we use img_info.pos, and for dims we use img_info.dims, etc.

Exploring ENVI

153

Extending ENVI

Library Routines

ENVIRasterQuery greatly simplifies the necessary IDL knowledge required to run a batch
process, so if lines like pos=lindgen(nb) still seem a bit esoteric to you, feel free to use it in
your own batch programs. You will need to keep a copy of it in the same directory you call batch
programs from, or elsewhere in your IDL path.
Note: You can see which directories are in your IDL path by typing the following at the command
line:
ENVI> print, !path

7. There is one other section of code to highlight from batch_envi_enh_lee_rq.pro, namely the block in
which ENVI is started:
; Start ENVI in headless mode unless ENVI is open.
e = envi(/current)
if e eq !null then begin
e = envi(/headless)
must_exit = 1B
endif else must_exit = 0B

This code checks to see if ENVI is open, and if it is not open, starts a new process. Otherwise, we
use the current ENVI process. A code block like this allows us to write a batch program that will
still run whether or not ENVI was open. Youll notice that the must_exit variable is assigned a
value of 1 in the case that ENVI was not open. We check on this and exit ENVI at the end of the
program if necessary with the following line:
; Exit ENVI unless ENVI was already open.
if must_exit then e.close

8. Next, open and look at batch_ica.pro. Note the following lines of code:
pro batch_ica, in_file, out_file99
compile_opt idl2, logical_predicate
[]
; If called from command line use command line arguments.
args = command_line_args(count=args_count)
if args_count then begin
in_file = args[0]
out_file = args[1]
endif

The code above enables batch_ica to be run either from the workbench or IDL command line, or
from an external process such as your operating system command line. In either case, the input file
and output file names must be passed as parameters. The way to call this from IDL is shown in the
next step.

9. To run batch_ica.pro hit the

button and then go to the command line. Type:

ENVI> batch_ica, file_which("boulder-etm.dat"), $


"C:\ ENVI_coursefiles\envidata50\extend\boulder_ica.dat"

10. Note that your output file path will probably differ. Also, if boulder-etm.dat is not in your
file path, you may need to hard code the input file path (it is located in your extend directory).
11. Now you can run this program multiple times from the command line and supply a different input

154

Exploring ENVI

ENVI Extensions

Extending ENVI

and output file each time, without worrying about what the settings are. Constructing programs like
this is referred to as modularizing them; breaking them into the necessary components so those
components can be re-used or called as needed. If you have a little bit of IDL programming
knowledge, its possible to do things like construct a string array of file names from a file search in
order to run your batch process on every file in a particular directory.
12. Also note that BATCH_ICA is written to be compatible with earlier versions of ENVI
(compile_opt idl2, logical_predicate). For this reason, it uses the procedural
interface to ENVI, and makes calls to ENVI_BATCH_INIT and ENVI_BATCH_EXIT rather than
e = envi(/headless) and e.close(). Note that if you want to share code with colleagues
using a version of ENVI prior to 5.0, your batch routines will need to be written this way instead.
You can consult the help topic on these routines for more information.
Optional: Note that there are other batch and programming examples included in your extend\src
directory in the course data. These include a few batch examples not discussed directly in the text that
make use of things like regular expressions, file routines, and GUI elements to help direct batch
processing. Each of these components is commented in the code at a detailed level to help a new user
learn how to use similar coding practices in their own batch programs.
Note on code use/license: Feel free to copy and paste from and/or use these batch programs as templates
for your own work. This code is not protected and is meant for instructional purposes. This code has no
warranty and represents no obligation from Exelis VIS, and therefore the following legal terms apply:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ENVI Extensions
You may have noted the presence of the Extensions folder in the ENVI Toolbox. Programs that are placed
in the Extensions folder, and that meet the necessary IDL criteria to be recognized by ENVI as extensions
are automatically accessible. These routines must end in .pro (text code) or .sav (compiled code), and
contain an IDL procedure that will execute when the tool is clicked on in the menu.

Exploring ENVI

155

Extending ENVI

ENVI Extensions

The Directories topic under the File Preferences contains the file path to the current Extensions File
Directory. For your system configuration, it may be necessary to make sure this exists somewhere in your
user space so you can modify its contents (on Windows, somewhere under your username folder, and on
Unix-based systems like Linux and Mac, somewhere in your home folder).
Note: If you do not have write permissions to the directory, you will need to change the Extensions File
Directory path to a location where you have write permissions prior to attempting the final two exercises of
this chapter.

A Template for ENVI Extensions


As with the batch examples, a quick template here is provided so that an experienced IDL programmer can
immediately begin converting existing ENVI and IDL programs to ENVI extensions.
pro envi_extension_template
compile_opt idl2
catch, envi_error
if envi_error ne 0 then begin
catch, /cancel
if obj_valid(e) then $
e.ReportError, 'ERROR: ', + !error_state.msg
message, /reset
return
endif
; Get ENVI session
e = envi(/current)
; Prompt for the input file

156

Exploring ENVI

ENVI Extensions

Extending ENVI

inFile=dialog_pickfile(dialog_parent=e.widget_id, $
title='Please select input file', $
/must_exist)
; Prompt for the output file
outFile=dialog_pickfile(dialog_parent=e.widget_id, $
title='Please select output file')
; Report as an error what the output file would have been.
e.ReportError, 'Output file would have been: ' + outFile
end

The initial error block is a general purpose ENVI error block that can be used with most ENVI 5.0
extensions. Note that the method e.ReportError is called from the ENVI object declared just below it in
the code block (e = envi(/current) and that both uses of GUI elements refer to e.widget_id as their
parent widget. In ENVI 5.0, many ENVI library routines are handled as methods of the ENVI process,
created with e = envi()for a new ENVI process or e = envi(/current)for an existing ENVI process.
When the above .pro file is copied into the current extensions directory and ENVI is restarted, it will appear
in the Extensions folder of the Toolbox:

The new tool name matches the name of the procedure declared as the last (and in this case only) procedure
in the file. When we double click it, it will run the code above, prompting the user for an input file and an
output file, then reporting what the output file would have been as an error (as the code currently does
nothing else).
Note: For the following examples we will walk through some of the code, but this course only gives limited
attention to programming ENVI. For more information, consult the Extending ENVI Course manual.
Individual routines and general topics can be examined in the help.

Exercise #8: Add a Program to ENVI Extensions


1. Using your Operating System, navigate to the enviout directory and create a folder called
active_envi_extensions. You will use this folder as your Extending ENVI directory for the
purposes of this course. Normally you would create this extensions folder in your home directory.
2. Using your Operating System browse to extend\src select urban_geo_pantex.pro and
copy it to the active_envi_extensions directory you just created.
3. You currently should only have IDL running. To start ENVI go to the command line and type:
IDL> e = envi()
4. In the ENVI interface click File Preferences then click on Directories.
5. Click to select Extensions File Directory you will see the button
appear on the right side of
the current active directory. Click the
to bring up a directory browser, then navigate to and
select the active_envi_extensions folder you created.
6. Restart ENVI. You can do this from ENVI directly by selecting File Exit or, if youd like, you
can use the IDL command line to do the same:
ENVI> e = envi(/current)

Exploring ENVI

157

Extending ENVI

ENVI Extensions

ENVI> e.close
IDL> e = envi()
7. Urban_geo_pantex should now be a tool available from the Extensions folder in the Toolbox:

8. Double click on urban_geo_pantex. You will be prompted to select an input file. Navigate to
envidata\extend and select urban_geo_sub.dat to run the process on this file. You see
this dialog to select the file because of the following code:
;Prompt for the input file
inFile=dialog_pickfile(dialog_parent=e.widget_id, $
title='Please select input file', $
/must_exist)
9. The file you selected will be loaded into the display. This loading is accomplished by the following
code:
imageRaster = e.OpenRaster(inFile)
view = e.GetView()
layer = view.CreateLayer(imageRaster)
10. As the image is loaded into the display, you will see the UrbanGeo dialog box open. You are
prompted to enter three different values, the GLCM Kernel Size, the number of Gray Levels, and
Enter Output Filename. Each of these components is put together using auto-managed widgets in
ENVI. Auto- managed widgets are not as fully featured as standard IDL widgets, but can be used to
quickly build ENVI interfaces when only a few different types of input are required.

The code that creates this dialog box (with explanatory comments) and captures the input from the
user is below.
; Set up gray level list for selection.
gl_list = ['8', '16', '32', '64', '128', '256']
; Set up window as top level base widget.
tlb = widget_auto_base(title='UrbanGeo')
; Make a row for our moving window / kernel size.
row1 = widget_base(tlb, /row)

158

Exploring ENVI

ENVI Extensions

Extending ENVI

; Set moving window / kernel size.


k_param = widget_param(row1, $
/auto_manage, $
default=5B, $
dt=1, $
floor=3B, $
ceil=21B, $
prompt='GLCM Kernel Size (odd pixels)', $
uvalue='k')
; Make a row for the toggle widget.
row2 = widget_base(tlb, /row)
; Toggle Gray Levels for GLCM
gl_toggle = widget_toggle(row2, $
/auto_manage, $
default=3, $
list=gl_list, $
prompt='Gray Levels: ', $
uvalue='gl_select')
; Prompt user to select output file.
out_f = widget_outf(tlb, $
/auto_manage, $
uvalue='out_file')
; Call the auto-managed widget manager.
result = auto_wid_mng(tlb)
if result.accept eq 0 then return
if (result.k mod 2B) ne 1B then message, 'Kernel size must be odd.'

11. Click Choose, browse to your output directory, and type pantex_test.dat for the file name.
Then click Open. Click OK to run the program.
12. You will see several different processes run with progress bars. PanTex actually performs several
GLCM (Gray-Level Co-occurrence Matrix) processes then calculates a minimum result through
band math. Because this code is modularized, the actual processing takes place in a different
procedure. This procedure is called by the following line:
ug_pantex, ENVIRasterToFID(imageRaster), $
result.out_file, $
kernel=result.k, $
g_levels = gl_list[result.gl_select]

Each of our widgets stored the user input in the structure labeled result. In calling the PanTex
algorithm programmatically, all we have to do to retrieve each of these values is dereference them
from the structure, as with result.out_file. If the user inputs c:\scratch\test.datas
their output file, then result.out_file resolves to c:\scratch\test.dat and this value is
passed to the ug_pantex procedure where it is used to determine the location to write the output.
13. When the process is finished, you will see the result added to the View:

Exploring ENVI

159

Extending ENVI

ENVI Extensions

This result is added by code similar to that in step 9:


; Add result to display
resultRaster = e.OpenRaster(result.out_file)
layer = view.CreateLayer(resultRaster)

Note: view was declared previously in the code (Step 9) with:


view = e.GetView()
14. The PanTex algorithm is meant to highlight built-up areas. Click on your result in the Layer
Manager to make it active, then use the transparency slider:
at the relationship between the originating data and its output.

to look

15. When finished, right click on View and select Remove All Layers.
16. Minimize the IDL Workbench.

Exercise #9: Download and Install an Extension


Note: You will have to be connected to the internet and have access to a web browser on a system in order
to download files for this exercise.
1. In a web browser, navigate to http://www.exelisvis.com.
2. Click on User community Code Library. The code library is the central repository for ENVI
users and Exelis VIS employees to share free code.

160

Exploring ENVI

Skills Check

Extending ENVI

3. If you dont see Google Maps Link on the Code Library page, type Google Maps Link in the
Search window and click Search. Then click on the link for it.
4. Click Download to get the Google Maps Link program (this program only works for Windows).
Save the file and note where it is going (likely your Downloads directory).
5. Browse to the directory that contains GoogleMapsLink.zip and unzip it. Read the
readme.txt file and follow the instructions (move the .sav file and the directory specified over to
your active_envi_extensions directory).
6. Another useful program is ENVIProgramGenerator.sav. This allows users to create batch
processes for ENVI. If you dont see this file listed on the Code Library page, type Program
Generator in the Search window and click Search. Then click on the link for it and download.
Then move the .sav file to your active_envi_extensions directory.
7. Restart ENVI and IDL. You should see the added programs listed in the Extensions folder of the
ENVI Toolbox. Try Google Maps Link later when you have a georeferenced file open and
displayed.
Note: To get Google Maps Link to run you need to right click on the files in the folder (gmals_link.css,
gmaps_link.htm, pin.png, and gmaps_link.sav) go to Properties and unblock them. Then change "opens
with" from MS Windows to IE for the gmaps_link.js file. Finally launch ENVI 5 in 32-bit mode.

Skills Check
At this point, you should know how to:
Work with Band and Spectral Math
Run ENVI from the IDL command line
Run a batch program
Access code contributions over the internet

Self Test
1. What are the three ways to extend ENVI?
2. What is the difference between .pro and .sav files?

Exploring ENVI

161

Chapter 10:

Color Transforms and


Data Fusion Techniques
Learning Objectives................................................................................................................ 164
Prerequisites .......................................................................................................................... 164
Required Tools for Completing This Module ........................................................................... 164
Associated Data ..................................................................................................................... 164
Introduction ............................................................................................................................ 164
Color Transforms ................................................................................................................... 165
Image to Image Registration .................................................................................................. 168
Data Fusion using Color Transforms ...................................................................................... 170
Skills Check ........................................................................................................................... 171
Self Test ................................................................................................................................. 172

Exploring ENVI

163

Color Transforms and Data Fusion Techniques

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Combine MODIS data with RADARSAT data in RGB composites
Transform color-composite images from RGB to HSV color space
Transform color-composite images from RGB to HSV color space
Enhance color-composite images with a saturation stretch
Create a synthetic color image from a gray scale radar image
Fuse high-resolution radar data with low-resolution multispectral data
Use the HSV color space to enhance image features

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. Also you should know how to
display an image in ENVI and work with the Layer Manager.

Required Tools for Completing This Module

ENVI 5.0
ENVI EX/FX license to run Feature Extraction

Associated Data

ch_MODIS_reflectance.dat
ch_rsat.dat

Introduction
This section of the course concentrates on a few of ENVIs data fusion techniques and display
enhancements using color transforms.
Often, a single sensor does not provide adequate images for a particular application. For example, clouds in
the scene may obscure critical regions of interest, or sensor resolution might limit the interpretation of
acquired images. Data fusion provides a means of combining data from various sensors to produce an image
with as much information as possible.
For example, visible sensors (such as MODIS) collect reflectance data in visible to mid-infrared
wavelengths, but clouds can obscure the data. You can georeference these data with Synthetic Aperture
Radar (SAR) data, which penetrate clouds, haze, and light rain, plus they provide information about
roughness, surface moisture, surface geometry, and topographic relief. You can then use different color
transforms to merge the two data types. These data fusion techniques allow four dimensions of data to be
projected into 3D color space. Fusing reflectance data and SAR data produces an image with useful
information, even in cloudy areas.
Note: The MODIS data used for this chapter was collected during the summer of 2011. It was downloaded
from the NASA MODIS site http://ladsweb.nascom.nasa.gov/ and was processed and georeferenced using
the MODIS Conversion Toolkit (MCTK) written by Devin White, PhD. This toolkit can be downloaded
from: http://www.exelisvis.com/language/en-US/UserCommunity/CodeLibrary.aspx. To run the MCTK in
ENVI5, simply unzip the bundle and drop it into the ENVI5 extensions directory. The original HDF data
was converted to an ENVI format file and a subset was created to make this data easier to work with in an
educational setting.

164

Exploring ENVI

Color Transforms

Color Transforms and Data Fusion Techniques

Color Transforms
Color transforms convert RGB images to other color spaces. In addition to the RGB color space, ENVI also
supports hue, saturation and value (HSV), as well as hue, lightness and saturation (HLS). By applying a
contrast stretch in another color space, you can highlight certain features of interest.

Exercise #1: Custom Stretching and the Photographic Stretch


One of the most common challenges when working with images over many regions on Earth is getting a
visually pleasing image when cloud cover is present. This exercise uses MODIS data over Chesapeake Bay
in the U.S. These data have seven spectral bands with a pixel size of 500 m 1000 m.
1. From the ENVI main menu bar, select File Open. Navigate to envidata\fusion, and select
ch_MODIS_reflectance.dat. Click Open. The image is displayed using a 2% Linear stretch.
2. If you still have your preferences set to automatically display a CIR image. If so, open the Data
Manger, right click on ch_MODIS_reflectance.dat and select Load True Color. The true
color image may be very dark because of the bright cloud cover. If so, click the Custom Stretch
button
. On the Custom Stretch dialog, type in 7 for the Linear (Percent Value) in the box at the
bottom of the dialog and hit ENTER on your keyboard. You should now be able to see many more
detail in the land area. Close the Custom Stretch dialog.
The MODIS data values for this image are floating point (decimal) numbers. In order to use Color
Transforms in ENVI, or for someone without image processing software like ENVI to be able to
display our image, you should save this displayed image as byte-scaled (0-255).
3. Make sure that your image zoom factor is set to 100%. If you have any border around your image,
this will be saved as part of the file in the next step.
4. Select FileChip View ToFile. Notice that you can select JPEG or TIFF to send this image to
someone without image processing software like ENVI. Set Output File type to ENVI.
5. Click the File Select folder. Navigate to envidata\ouput and enter
ch_MODIS_TrueColor.dat for the output file name and click Open then OK.
6. Click the Cursor Value icon and roam around the image. Notice that the values in
ch_MODIS_TrueColor.dat are byte values, while the values in the original image are floating
point numbers. We have now created an image to which we can apply color transforms.
7. In the ENVI Toolbox, select Transform Photographic Stretch.
8. In the RGB Photographic Stretch Input Bands dialog, click on Band 3 for R, Band 2 for G, and
Band 1 for B from ch_MODIS_TrueColor.dat. Click OK.
9. In the RGB Photographic Stretch Parameters dialog, navigate to envidata\enviout and enter
ch_MODIS_photo.dat for the Output Filename. Click Open, then click OK.
10. A 3-band photographic stretch image will be displayed. Use the Transparency slider to compare this
image with the previous one.
11. Right click on View in the Layer Manager and select Remove All Layers.

Exercise #2: Automatic Saturation Stretch


One of the most common color transforms is a saturation stretch, which enhances the color saturation of an
RGB display. ENVI transforms input data from RGB to HSV space and performs a Gaussian stretch on the
saturation band to fill the saturation range. It then transforms HSV data back to RGB space.

Exploring ENVI

165

Color Transforms and Data Fusion Techniques

Color Transforms

1. Go to the Data Manager and right click on ch_MODIS_reflectance.dat.


2. Select Load CIR. A color infrared image is displayed and shows up in the layer manager as a 2,1,4
band combination.
Remember that the data values are floating point numbers. In order to use Color Transforms in
ENVI, you should save this displayed image as byte-scaled (0-255).
3. Make sure that your image zoom factor is set to 100%.
4. Select FileChip View ToFile.
5. Set Output File type to ENVI.
6. Click the File Select folder. Navigate to envidata\ouput and enter ch_MODIS_CIR.dat for
the output file name. Click Open then click OK.
7. In the ENVI Toolbox, select Transform Saturation Stretch. A saturation stretch enhances the
color saturation of an RGB display.
8. In the Saturation Stretch Input Bands dialog, click on Band 1 for R, Band 2 for G, and Band 3 for
B from ch_MODIS_CIR.dat. Click OK.
9. In the Saturation Stretch Parameters dialog navigate to envidata\enviout and enter
ch_MODIS_saturate.dat for the Output Filename. Click Open then click OK. A 3-band
saturation stretch image will be displayed.
10. To observe the differences between the original band CIR image and your saturation stretch image,
you can use portals as you learned in a previous lesson, the Transparency slider, or you can simply
turn layers on and off.

Exercise #3: Transforming to a Different Color Space


In addition to the RGB color space, ENVI also supports hue, saturation and value (HSV), as well as hue,
lightness and saturation (HLS). By applying a contrast stretch in another color space, you can highlight
certain features of interest.
1. To transform an RGB image to HSV, select Transform Color Transforms RGB to HSV
Color Transform from the ENVI Toolbox.
2. In the RGB to HSV Input Bands dialog, click on Band 1 for R, Band 2 for G, and Band 3 for B
from ch_MODIS_CIR.dat. Click OK.
3. In the RGB to HSV Parameters dialog, navigate to envidata\enviout and enter
ch_MODIS_HSV.dat for the Output Filename. Click Open then click OK.
4. An HSV color representation of the MODIS image is displayed. You could now manipulate the
HSV bands to enhance specific features, save the image and transform back from HSV to RGB
color space.
5. Right click on View in the Layer Manager and select Remove All Layers.

Exercise #4: Synthetic Color for One-Band Images


ENVI provides a tool that can generate an RGB color composite from a gray scale (including radar) image.
ENVI applies high- and low-pass filters to the image and performs an HSV to RGB transformation with the
low frequency information assigned to hue, the high frequency information assigned to intensity, and a
constant value assigned to saturation. This process improves the display of subtle, large-scale features while

166

Exploring ENVI

Color Transforms

Color Transforms and Data Fusion Techniques

retaining fine detail. This exercise uses RADARSAT data from the Chesapeake Bay region, with a pixel
size of 100 m.
1. Select File Open. Navigate to envidata\fusion, and select ch_rsat.dat. Click Open.
A grayscale image of the RADARSAT data is displayed.
2. In the ENVI Toolbox, select Transform Synthetic Color Image. A Synthetic Color Input File
dialog appears.
3. Select Band 1 under ch_rsat.dat and click OK.
4. In the Synthetic Color Parameters dialog you should choose kernel sizes for the high- and low-pass
filters that correspond to the size of the transition from surface scattering to slope-dominated
scattering in the radar image. Values used for the saturation image are 0 to 1. Higher values produce
more saturated colors. For this exercise, use the default kernel values.
In the Enter Output Filename field, enter ch_synth.dat and click OK. The synthetic color
image is displayed and is listed in the Layer Manager.
5. The synthetic color image is displayed with no stretch. You can experiment with different stretches
to enhance the color contrast.
6. You can compare the synthetic color image to the original image using Portals, or simply by
unchecking and checking layers in the Layer Manager.
What features seem to stand out more in the synthetic color image? Be sure to look for enhanced
features in the areas away from Chesapeake Bay.
7. One display technique that works very well for images like this is to use the transparency slider to
be able to view multiple images at one time. If you have a Portal open, close it. Now use the
Transparency slider to make the top layer semi-transparent. A value of about 40 seems to work well
for this image combination. You can make useful images using this technique. See the image below
for an example.

8. To prepare for the next exercise, right click on the color synthetic image and remove it from the
Layer Manager.

Exploring ENVI

167

Color Transforms and Data Fusion Techniques

Image to Image Registration

Image to Image Registration


The first step in data fusion is to make sure the data sets are registered correctly to one another. The exercise
below will show you how to work with the Image Registration Workflow.

Exercise #5: Image to Image Registration


1. If the RADARSAT image is not still displayed, load it as a grayscale image from the Data Manager.
2. You will fuse the SAR image with the saturation stretch CIR image you created in the previous
exercise. The file ch_MODIS_saturate.dat should still be in the Data Manager. Right click on
this file in the Data Manager and select Load Default.
3. Adjust the transparency of the overlying image. Notice that the spatial resolution of the MODIS
image is much lower than the RADARSAT image. Notice also that the MODIS image has been
reprojected to match that of the base image (RADARSAT). Look at the listing for the MODIS
image in the Layer Manager, it will say REPROJECTED. Use the Data Manager to view the File
Information for both of these files. The File Information tab gives projection and datum information
for the selected data set.
4. In the ENVI Toolbox, select Geometric Correction Registration Image Registration
Workflow.
5. In the File Selection dialog of the Workflow, select ch_rsat.dat as the Base Image File.
6. In the File Selection dialog of the Workflow, select ch_MODIS_saturate.dat as the Warp
Image File. Click Next.
7. In the Tie Points Generation dialog, leave all the default settings and click Next. Several tie points
will be generated.
8. In the Review and Warp panel, toggle between the two images by using the Switch to Warp or
Switch to Base button.

Base Image with Tie Points

168

Exploring ENVI

Image to Image Registration

Color Transforms and Data Fusion Techniques

Warp Image with Tie Points


9. Click on Show Table. The Tie Points Attribute Table lists all the points, their pixel location in both
the base and warp image, their Score and their Error. The overall error is specified at the bottom of
the table. You can right click on each column heading and specify the sorting order. This is most
useful for sorting the ERROR column because it allows you to quickly see which points have the
highest error. You may choose to select these points and delete them.
10. There are a couple of ways to highlight and check individual points. Click on the less than and
greater than buttons at the bottom of the Tie Points dialog to go to each point in succession
according to the current order. Click on the button to the left of a PONT_ID to go to a specific
point. Close the Tie Points Attribute Table.
11. Click the Show Error Overlay button
. Dark grey areas in the overlay represent tie points with
negligible error magnitudes, while orange-to-white areas represent tie points with higher error
magnitudes. It is recommended that you examine the tie points in orange-to-white areas and delete
those tie points or add new ones as needed. Dark-red to bright-red areas represent tie points with
error magnitudes within a reasonable range (2.5 to 10.). Examine the tie points in those areas
depending on the level of accuracy you desire. Remember that higher errors do not necessarily
indicate bad tie points. There may be changes in topography that affect the score or error. The best
way to determine tie point accuracy is to visually examine their location in the base and warp
images. Click the overlay button to turn it off.
12. Click the Start Editing button and view the instructions below it. You can choose to Add tie points
or delete tie points. Click Stop Editing.
13. Click the Preview checkbox to view a portal that allows you to view the warp result. Right click in
the portal and select Blend, Flicker, or Swipe. The portal is locked into place but you can move the
image under it by holding the middle mouse button down in the gray scale RADARSAT image and
panning. When finished examining the potential result, uncheck the Preview box.
14. For this example, ENVIs automatic tie point generation may have done a sufficient job of
registering these two images without any user intervention. If that is not the case, go back to the Tie
Points Generation step and add Seed Points. Then return to the current step. When you are satisfied
with your tie points, click Next to accept the registration and warp the RADARSAT image.

Exploring ENVI

169

Color Transforms and Data Fusion Techniques

Data Fusion using Color Transforms

15. In the Export dialog, select ENVI for Output Image file type. Click Browse and navigate to
envidata\enviout. Enter ch_MODIS_saturate_warp.dat and click Open.
16. Click the box.
17. Click the Browse button for Export Tie Points to ASCII and navigate to envidata\enviout.
Note that the default file name is ch_rsat_tie.pts. Click Open.
18. Click Finish.
19. The warped (registered) MODIS image is displayed and listed in the Layer Manager.
20. Use Portals, the Transparency slider or simply check and uncheck image layers to compare the
warped image to the original MODIS color composite and the RADARSAT gray scale image.
21. When finished right click on View in the Layer Manager and choose Remove All Layers.

Data Fusion using Color Transforms


You can use color transforms to merge two data sets with different spatial resolutions by replacing the value
or lightness band of an HSV or HLS image with a co-registered, high resolution image. This technique is
often used to sharpen a multispectral image by combining it with a high resolution panchromatic image of
the same area. ENVI provides automated methods to perform the most common color transforms and
fusions, and it also allows you to execute user-defined transforms.

Exercise #6: Image Fusion using HSV Sharpening


ENVI's HSV sharpening tool automatically merges low spatial resolution color data with high spatial
resolution gray scale data and resamples to the high resolution pixel size. The images must be georeferenced
or have the same image dimensions for this tool to run. The HSV sharpening tool performs an RGB to HSV
color transform, replaces the intensity band with the high spatial resolution image, resamples the hue and
saturation bands to this high resolution pixel size, and transforms the HSV image back to RGB space.
This exercise sharpens a low spatial resolution MODIS Chesapeake Bay image with a high spatial resolution
RADARSAT image. We will use the MODIS image that we warped (georeferenced) in the previous
exercise.
1. From the ENVI Toolbox, select Image Sharpening HSV Sharpening. A Select Input RGB
Input Bands dialog appears.
2. Select RGB bands from the ch_MODIS_saturate_warp.dat image that you created in the
previous exercise. Click OK.
3. In the High Resolution Input File dialog, select Band 1 of ch_rsat.dat and click OK.
4. In the HSV Sharpening Parameters dialog click the Resampling drop-down list, and select Cubic
Convolution.
5. In the Enter Output Filename field, enter ch_hsv.dat. Click OK. The HSV-sharpened image is
displayed.

170

Exploring ENVI

Skills Check

Color Transforms and Data Fusion Techniques

RADARSAT and MODIS Fusion Product using HSV Sharpening


6. Reload the high resolution gray scale ch_rsat.dat image and compare it with the HSV
sharpened result.
How does the sharpened image compare to the lower resolution RGB image? Did the information
content increase?
7. Open the Data Manager and click the Close All Files button.

Skills Check
At this point, you should know how to:
Enhance color-composite images with a saturation stretch

Exploring ENVI

171

Color Transforms and Data Fusion Techniques

Self Test

Go back and forth between different color spaces


Create a synthetic color image
Fuse high-resolution data with low-resolution data

Self Test
1. How can you make a synthetic color image from a grayscale image?
2. What tools can you use to fuse high-resolution and low-resolution data?

172

Exploring ENVI

Chapter 11:

Feature Extraction
Learning Objectives................................................................................................................ 174
Prerequisites .......................................................................................................................... 174
Required Tools for Completing This Module ........................................................................... 174
Associated Data ..................................................................................................................... 174
Feature Extraction Workflow .................................................................................................. 174
Extracting Dark Rooftops with Rule-Based Classification ....................................................... 175
Skills Check ........................................................................................................................... 183
Self Test ................................................................................................................................. 183

Exploring ENVI

173

Feature Extraction

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Use Feature Extraction to perform a rule-based classification
Create and edit vectors

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. Also you should know how to
display an image in ENVI and work with the Layer Manager.

Required Tools for Completing This Module

ENVI 5.0
ENVI EX/FX license to run Feature Extraction

Associated Data

QB_NOLA_sub Quickbird image of New Orleans, LA.

Feature Extraction Workflow


ENVIs Feature Extraction is a module for extracting information from high-resolution panchromatic or
multispectral imagery based on spatial, spectral, and texture characteristics. You can extract multiple
features at a time such as vehicles, buildings, roads, bridges, rivers, lakes, and fields. Feature Extraction is
designed to work with any type of image data in an optimized, user-friendly, and reproducible fashion so
you can spend less time understanding processing details and more time interpreting results.
ENVI Feature Extraction is the combined process of segmenting an image into regions of pixels, computing
attributes for each region to create objects, and classifying the objects (with rule-based or supervised
classification) based on attributes, to extract features. You can also simply output the segmentation result.
The workflow allows you to go back to previous steps if you want to change your settings.
.

174

Exploring ENVI

Extracting Dark Rooftops with Rule-Based Classification

Feature Extraction

Extracting Dark Rooftops with Rule-Based


Classification
Rule-based classification lets you define features by building rules based on object attributes. Rule-based
classification is a powerful tool for feature extraction, often performing better than supervised classification
for many feature types. Rule-building is primarily based on human knowledge and reasoning about specific
feature types: For example, roads may be elongated, some buildings approximate a rectangular shape,
vegetation has a high NDVI value, and trees are highly textured compared to grass.
Taking this concept a step further, you can define a rule using one or more conditions; for example, you
could define a rule set for lake as the following:

Objects with an area greater than 500 pixels AND


Objects with an elongation less than 0.5 AND
Objects with a Normalized Difference value less than 0.3

Once you have created a set of rules and they seem to work well for your region of interest, you can save the
rule set for later use.

Exploring ENVI

175

Feature Extraction

Extracting Dark Rooftops with Rule-Based Classification

Exercise #1: Rule-Based Feature Extraction


A license is required to run Feature Extraction. If you need this license please contact your sales
representative.
1. From the ENVI menu bar, select File Open.
2. Navigate to envidata\Fx and open QB_NOLA_sub. This image is a QuickBird subset of
New Orleans, LA saved to ENVI raster format. A CIR image should be displayed based on your
Preferences.
3. The bright objects in this scene dictate that most of the image is a bit dark. Try a 1% or 2%
Linear contrast stretch.
4. In the Toolbox, click the plus symbol for Feature Extraction to expand the listing. Double
click on Rule Based Feature Extraction Workflow. The Data Selection dialog appears.
5. QB_NOLA_sub should be selected as Input Raster. Note that you can use a Mask as well as
Ancillary Data (for example a Digital Surface Model extracted from LiDAR data). If the input
data is in ENVI format, any pixel values specified in the Data Ignore Value field of the
associated header file will be treated as mask values and will not be processed by Feature
Extraction.
6. Click on the Custom Bands tab and enable Normalized Difference and Color Space by
clicking their boxes. By default the bands used for the Normalized Difference are the nearinfrared and red wavelengths. This is essentially an NDVI useful for delineating vegetation.
Click Next. The Object Creation dialog appears.
7. Click on the Preview box to display a Preview Portal showing the affect of the current
segmentation settings. You can move the Preview Portal around the image and resize it.
8. You want to choose the highest Scale Level that delineates the rooftops as well as possible. If
you click on either side of the Scale Level slider the value will change by ten units. You can
also change values either by moving the slider itself or typing in a value under Scale Level.
Choosing a high Scale Level causes fewer segments to be defined, and choosing a low Scale
Level causes more segments to be defined. If you choose too high of a Scale Level, the
boundaries between segments will not be properly delineated and you will lose features of
interest. You should ensure that features of interest are not grouped into segments containing
other features. A value around 40.0 seems to delineate the rooftop boundaries while preserving
some detail in their shapes. Move the slider or type this value in. The Preview Portal updates to
show the change in segmentation.
9. The Merge step groups similar adjacent segments by re-assembling over-segmented results. It is
useful for merging small segments into larger ones. You should ideally choose the highest
Merge Level that delineates the boundaries of features as well as possible. For this dataset, set
the Merge Level to a value near 82.0.
Note: The Texture Kernel Size parameter determines the size (in pixels) of a moving box centered
over each pixel in the image. Texture attributes are computed for each kernel. An odd number
between 3 and 19 is required. The default value is 3. Select a higher kernel size if you are
segmenting large areas with little texture variance such as fields. Select a lower kernel size if you
are segmenting smaller areas with higher variance such as urban neighborhoods. Click Next. The
segmentation process will run and attributes of the segments will be computed.

176

Exploring ENVI

Extracting Dark Rooftops with Rule-Based Classification

Feature Extraction

10. Feature Extraction creates a Region Means image based upon the segmentation process, adds it
to the Layer Manager, and displays it in the image window as the top layer. Each segment is
assigned the mean band values of all the pixels that belong to that region. To view the original
image, simply uncheck the Region Means image. The workflow panel now shows the Create
Rules step. Click on the Add Class icon
.

11. A New Class 0 is listed under the All Classes folder. Under it is an undefined Rule and a default
Attribute for that class. Click on the New Class and its Class Properties panel to the right will

Exploring ENVI

177

Feature Extraction

Extracting Dark Rooftops with Rule-Based Classification

become active. Change the Class Name to Roofs. If you click on Class Color you can access a
pull-down menu to change the color.
12. Click on the Rule and note that you can change the Rule Weight in the Rule Properties panel.
The left-most icon above All Classes has changed ( ) to allow you to add an Attribute to the
Rule.
13. Click on the default attribute (Spectral Mean for Band 1). A histogram appears that allows you
to set minimum and maximum thresholds for this attribute. Click on the Dock/Undock
Histogram Window icon . This allows you to resize the histogram for better viewing. At the
top of the histogram are the minimum and maximum values for this attribute (Band 1 Mean).

14. Click in the Preview box to open up a Preview Portal. The Preview Portal displays a rule
confidence image, which shows the relative confidence of each segment belonging to a feature.
The rule confidence image is a solid-red color until you set thresholds for the attribute. Adjust
the minimum (green) and maximum (blue) sliders. Areas that dont fall within the set
thresholds will appear black. You can also type values into the minimum and maximum text
windows at the top of the histogram.
15. On the right side of the Create Rules panel is a box labeled Show Attribute Image. Make sure
the attribute is selected, then click on this box and a gray scale image will appear. The values in
this image represent the average value of Band 1 for each segment. Viewing the attribute image
is useful for determining if this particular attribute will be useful in helping to pull out features
of interest. If the roofs have a high contrast relative to the other objects, then this attribute is
useful. You can adjust the image transparency to view the underlying image if needed, using the
Transparency slider on the main ENVI toolbar. Resize the Portal and move it around to help
you decide if the mean value of band 1 is useful for selecting roofs in this scene.
Rule-building is primarily based on human knowledge and reasoning about specific feature types.
To extract rooftops from this image what characteristics do you think may be useful? Below is a list
of possibilities.

Buildings and rooftops have low Normalized Difference Vegetation Index (NDVI) values.

The shape of rooftops approximates a rectangle.

The area of rooftops of residential buildings is within a certain range, compared to


industrial or other types of buildings.

The rooftops of interest are relatively dark, so they should have an average pixel value that
is low, particularly in the green band.

The typical workflow for building rules is to begin with one attribute, test it on extracting your
feature of interest, then use more attributes to filter out all other features from the scene so that you
are left only with your feature of interest.

178

Exploring ENVI

Extracting Dark Rooftops with Rule-Based Classification

Feature Extraction

NDVI would be a good criterion to start with in this example, because you know that buildings have
lower NDVI values than vegetation. You could use ENVIs Vegetation Suppression tool with this
image prior to running Feature Extraction, but for this exercise, try filtering out vegetation using
attributes.
16. De-select Show Attribute Image. Then under the Attributes tab, from the Type pull-down menu,
make sure Spectral is selected. Then from the Band pull-down menu, select Normalized
Difference. Then in the histogram for that attribute, set the maximum value to 0.3 by typing this
number into the text box on the right side of the histogram. Press Enter. This is a typical NDVI
value that has been used to delineate vegetation. If you have the Preview Portal open, the rule
confidence image is updated and areas of vegetation should now be blacked out.
Tip: It may be easier to visually pick out features of interest from the original image rather than
the Region Means image. If this is the case, uncheck the Region Means image in the Layer
Manager.

17. Click on the Advanced tab in the Create Rules dialog. Note that you can adjust the weight for
this attribute. From the Algorithm pull-down menu, Binary means that a segment either matches
the attribute threshold(s) and gets a value of 1, or it does not match and gets a value of 0.
18. Make sure the attribute is selected, then select Linear from the Algorithm pull-down menu.
Segments will now have values ranging from 0 to 1. In the rule confidence image in the Preview
Portal, you may see varying intensities of red. Note that Tolerance is set to 5.0. If you set the
tolerance to 0.0, the Linear Algorithm is essentially set to binary. Select Quadratic from the
Algorithm pull-down menu. Experiment with different Tolerance values. Change the
Algorithm back to Linear.
19. Now consider the next characteristic of roofs. The shape of rooftops approximates a rectangle.
You can use the Rectangular Fit attribute to filter out the non-rectangular objects from the
image. Click Rule. The left-most icon above will update to become Add Attribute to Rule
.
Click on it and another Attribute (the default) will be listed underneath the Rule.
20. Click on the Attributes tab, then select Spatial from the Type pull-down menu. From the Name
pull-down menu select Rectangular Fit.
21. Click on Show Attribute Image. The Preview Portal will update to show this gray scale image.
To get an idea of what threshold to use for this attribute, click on the Cursor Value icon and
read values for rooftop segments as you move your cursor over the attribute image. You should
typically see values above 0.5.

Exploring ENVI

179

Feature Extraction

Extracting Dark Rooftops with Rule-Based Classification

22. De-select Show Attribute Image. With Rectangular Fit, leave the maximum value alone and
only adjust the minimum value. Experiment with different minimum values by clicking-anddragging the left-most slider on the histogram. If you set too high of a minimum value, you will
lose the rooftops in the rule confidence image. If you set too low of a minimum value, you
begin to pick up unwanted driveways. Set the minimum value to 0.50. Segments that low
Rectangular Fit values will be black in the Preview Portal. To help you compare to the original
image either click on the Portal to select it and then adjust the Transparency slider in the main
ENVI menu, or move your cursor to the top of the Portal and turn on Flicker by clicking the
green Run arrowhead . Click on the Pause icon to stop Flicker.
23. To view how thresholds for both attributes will affect the result, click on All Classes.
24. From the rule confidence map in the last step, you may have noticed some unwanted, small
objects. In addition, there are some larger road features that should be eliminated. If you are
extracting rooftops from houses, you know that the area of the rooftops is within a certain range
compared to other types of buildings (such as industrial). You can use the area attribute to
further define your rule set. Click Rule. Then click Add Attribute to Rule
.
25. Select the default attribute that appears, then select Spatial from the Type pull-down menu.
From the Name pull-down menu select Area.
26. Experiment with different minimum and maximum area values in the histogram, and notice
their results in the rule confidence image. A range of 75.0000 to 800.0000 works well in
extracting residential rooftops. There are some buildings that are close together and part of the
same segment, so their areas are larger than a single house. You might have to type the high
threshold value in if you cant adjust the slider to it.
27. Now that you have filtered out vegetation, non-rectangular shapes, and small and large features,
the next step is to filter out bright buildings. Click Rule. Then click Add Attribute to Rule
.
28. Select the default attribute that appears. Spectral should be listed as Type. From the Name pulldown menu select Spectral Mean. From the Band pull-down menu select Band 2.
29. Experiment with different minimum and maximum area values, and notice their results in the
rule confidence image. A maximum value of 550.0 works well in eliminating bright features.
The rule set in the Create Rules dialog should now look similar to the following:

180

Exploring ENVI

Extracting Dark Rooftops with Rule-Based Classification

Feature Extraction

30. Click All Classes and make sure the Preview Portal is selected. Move the Preview Portal around
the image to look at classification results for different areas. Click inside the Preview Portal,
then use the Transparency slider in the ENVI Zoom toolbar to increase the transparency of the
Preview Portal. By doing this, you can preview the classification results over the original image:

31. If you wish, you may re-adjust some of the attribute thresholds by selecting a particular attribute
and adjusting its histogram. There may be some road sections that are being classified as roofs.
Can you think of an attribute you could use to eliminate road segments? If you have time, you
might try Elongation. For now, the rule set that you just built extracts the dark rooftops fairly
well. Some errors remain, but you can clean up these with ENVIs vector editing tools after you
run the classification.
32. Once you have defined a rule set that works well in extracting dark rooftops, you can save the
rule set to an XML file. You can restore and use this rule set as a starting point for a different
scene, for example, so that you wont have to rebuild the entire rule set. Click the Save Rule
Set As button . Navigate to C:\ENVI_coursefiles\envidata\enviout and save
the rule as Roofs.rul. To restore the rule set in the future, click the Restore Rule Set button
.
33. When you are satisfied with the classification results, click Next in the Create Rules dialog. The
classification will be performed on the whole scene.
34. In the Save Results dialog Export Classification Vectors will be selected. All classes will be
saved to a single shapefile by default. Merge Adjacent Features is selected by default. This
may help in cases where angled rooftops with different brightness values were separated into
different segments. However, there may be some buildings that are next to one another that wil
be merged as well. For now, keep Merge Adjacent Features and Export Attributes selected.
The output root file name will be the same as the input data with vectors added.
35. Click on the Export Raster tab. By default, a classification image will be created. If you select
Export Segmentation Image a multispectral region means image will be created with values that
represent mean spectral values. It will have segmentation as part of the root file name.
36. Click on the Advanced Export tab. Export Attributes Image will create a multi-band image
where each band is a specific attribute. Export Confidence Image will create an image that

Exploring ENVI

181

Feature Extraction

Extracting Dark Rooftops with Rule-Based Classification

shows the relative confidence of each object belonging to a class. The higher the value, the
higher the confidence. A separate band will be created for each class exported.
37. Click on the Auxiliary Export tab. Export Feature Ruleset will save the rules that you have
defined. Export Processing Report will create a text report that summarizes the segmentation
levels, rules, and attributes that you used.
38. Make sure all output will go to C:\ENVI_coursefiles\envidata\enviout. Then
click Finish. Feature Extraction will create all the output you requested.
39. When processing is finished, the vectors and classification image will be displayed above the
input data. You will do some editing of the vector layer, so deselect (un-check) the
QB_NOLA_sub_class.dat classification image in the Layer Manager.
40. To better view your vector layer, click on QB_NOLA_sub in the Layer Manager to select it and
then adjust its transparency using the Transparency slider.

41. In ENVI you can create vector records in an existing vector layer as well as edit vector records
and vertices. In order to edit a layer it must be set as the active layer by right-clicking on it in
the Layer Manager window and selecting Set as Active Layer. If only one vector layer is
present, it is active by default. Below are the vector edit tools that can be selected.

42. To add another vector to the currently active vector layer, click on the Vector Create button
and place vertices by clicking in the display window. A right click will bring up a pop-up menu
to allow you to Accept or Clear your changes. When a vector layer has been modified, the icon
next to the layer name in the Layer Manager changes to a stippled pattern , to indicate the
layer has changed. You can save or discard those changes as needed. Add a few building
vectors where they are missing.
43. Click on the Vector Edit. Find an area where there are vectors you wish to delete. Zoom in to
see more detail if you wish. Completely enclose one or multiple vectors to high light them.
Then right click and choose Delete. If you still see the polygon then it is actually part of a
scene-wide vector. Click on it and if you see most every polygon highlighted, right click and

182

Exploring ENVI

Skills Check

Feature Extraction

choose Delete. This gets rid of the scene-wide vector. Note that in this Vector Edit mode you
can also Remove Holes, Smooth, Rectangulate, etc. highlighted vectors. Experiment with
these options.
44. Click on the Vertex Edit. Select a vector. You will see nodes defining the shape of the vector.
If you click on a node, you can drag it to another position. You can also right click and select
Insert Vertex, Delete Vertex, etc. from a pop-up menu. Experiment with editing vertices.
When you are finished, right click and choose Accept Changes.
45. Move around the image to find a polygon that encloses one or more houses. Select the vector,
then to split this polygon in two, right click on one vertex where youd like the split to occur
and choose Mark Vertex. Right click on the other side of the polygon where the split should
occur and choose Mark Vertex. Half of the polygon will be highlighted as shown below.

46. Now right click and choose Split at Marked Vertices. You should now have two polygons.
You may wish to move some vertices after the split. After you have made some edits to the
vector layer, right click in the display and select Save. Click OK to the Save question.
47. Open the Data Manager and click on Close All Files

Skills Check
At this point you should:
Know how to perform a rule-based classification
Know how to set thresholds for attributes in Feature Extraction
Know how to edit vector layers

Self Test
1. What information is saved in the Feature Extraction Processing Report?

Exploring ENVI

183

Chapter 12:

Mosaicking in ENVI
Learning Objectives................................................................................................................ 186
Prerequisites .......................................................................................................................... 186
Required Tools for Completing This Module ........................................................................... 186
Associated Data ..................................................................................................................... 186
Introduction ............................................................................................................................ 186
Skills Check ........................................................................................................................... 189
Self Test ................................................................................................................................. 189

Exploring ENVI

185

Mosaicking in ENVI

Learning Objectives

Learning Objectives
In this chapter you will learn how to:
Create a georeferenced mosaic

Prerequisites
For this chapter it helps to have a basic understanding of remote sensing. You should know how to display
an image in ENVI and work with the Layer Manager. You should also know how to use the contrast stretch
tool.

Required Tools for Completing This Module

ENVI 5.0

Associated Data

NSydney.dat and SSydney.dat - ASTER scenes of the region around Sydney, Australia.

Introduction
Mosaicking is the process of combining multiple images into a single composite image. With mosaicking,
you can combine images that are not georeferenced with pixel-based mosaicking (e.g., lay out images for
publication or map composition), or combine georeferenced images into an image covering a larger
geographic area. ENVI provides an interactive method for making a pixel-based mosaic and also
automatically placing georeferenced images within a georeferenced output mosaic. ENVI also provides
tools for common mosaic requirements such as blending edges (feathering), image border transparency,
changing base projections, and color balancing. ENVI's Virtual Mosaic function allows you to optionally
create and display mosaics without creating large output files.

Exercise #1: Georeferenced mosaicking


In this exercise, you will mosaic two visible near-infrared (VNIR) ASTER bands with a pixel size of 15 m.
The data are georeferenced to a UTM projection.
1. From the ENVI main menu bar, click on the Open folder icon. Navigate to envidata\aster,
and select both NSydney.dat and SSydney.dat. Click Open. Georeferenced images are
automatically positioned within the output mosaic according to their geographic coordinates.
A color-infrared (CIR) image is best with ASTER VNIR data. Make sure you have that band
combination for both scenes. The near-infrared band should be displayed as red, the red band
displayed as green and the green band displayed as blue.
2. Click on the Zoom To Full Extent icon in the ENVI menu bar. Change the contrast stretch for each
image by selecting from the stretch pull-down menu. A Linear 1% or 2% contrast stretch works
well for these scenes.
Because the NSydney.img was acquired on November 26, 2000 and the SSydney.img was
acquired on October 12, 2001, there is a difference in scene illumination between the images that is
apparent when the two images are displayed side-by-side. If you mosaic these two images without
color balancing, a noticeable seam will occur along the image boundaries where they join.
To minimize these differences, you can use color balancing during the mosaic process. Color
balancing matches the statistics from one image to another image. Gains and offsets are calculated

186

Exploring ENVI

Introduction

Mosaicking in ENVI

for each band from the fixed image and applied to the adjusted image(s), so the adjusted image(s)
has the same statistical range. The statistics can be calculated from entire images or only from
overlapping areas.
3. When scenes overlap as these do it is useful to be able to see through the non-data values. To do
this click on Raster Management Edit ENVI Header. Then in the Edit Header Input File
choose the Sydney that is the top layer and click OK.
4. In the Header Info dialog, click Edit Attributes, then select Data Ignore Value. Type in 0, then
click OK. After the header is edited, the image will have to be redisplayed. You can edit the header
file for the other Sydney scene if you wish.
5. From the ENVI Toolbox expand the Mosaicking folder. Then double click on Georeferenced
Mosaicking. A Map Based Mosaic dialog appears.
6. From the Map Based Mosaic dialog menu bar, select Import Import Files and Edit Properties.
A Mosaic Input Files dialog appears.
7. Select SSydney.dat and NSydney.dat and click OK. An Entry dialog appears.
8. The Entry dialog title bar includes the name of the image for which you are entering mosaic
parameters.
9. In the Data Value to Ignore field, enter 0. Overlap areas with this value will be transparent,
allowing underlying images to show through.
10. In the Feathering Distance field, enter 10 pixels.
Edge feathering is used to blend or blur the overlapping seams between mosaicked images. The
specified feathering distance is blended using a linear ramp that averages the two images across that
distance. Cutline feathering is used to blend the boundary between two overlapping images using a
specified blending distance to blend the images along the cutline. You will not use a cutline in this
exercise.
11. In the Red field, enter 3. In the Green field, enter 2. In the Blue field, enter 1. The items in this
block of the dialog only affect the appearance of images in the Mosaic tool.
12. If this is the entry dialog for SSydney.dat select the Adjust radio button. The SSydney.dat
image will be adjusted to match NSydney.dat because it is slightly darker, and you want a
brighter mosaicked image. If this is the entry dialog for the NSydney.dat image select the Fixed
radio button.
13. Click OK. The next entry image dialog appears. If this is the entry dialog for SSydney.dat select
the Adjust radio button. If this is the entry dialog for the NSydney.dat image select the Fixed
radio button. The Background See Through and Feathering fields keep the same values as the
previous entry image dialog.
14. Click OK. The Mosaic is displayed. You should see through the zero values of the top image. If you
decide to change any options, right click on an image and select from the pop-up menu, or right
click on a file listing at the bottom of the dialog and select an option. Note that you can change
which image is on top.

Exploring ENVI

187

Mosaicking in ENVI

Introduction

15. From the Mosaic dialog menu bar, select File Apply. A Mosaic Parameters dialog appears.
16. In the Enter Output Filename field, enter Sydney_mos.dat. Keep the Background Value of 0
if you want non-data pixels to be black. If you want non-data pixels to be white, type in a
Background Value of 255 (the value to use for byte data).
17. In the Color Balance using field keep the stats from overlapping regions option.
18. Click OK to start the mosaic process. After processing is complete, the mosaic appears in the
Available Bands List.
19. Open the Data Manager if it is not open already and right click on Sydney_mos.dat and select
Load CIR.
20. Adjust the contrast stretch, then zoom into an area where the two images join to see how well the
color balancing worked.
21. When you are finished examining the mosaic, click on the Close All Files in the Data Manager and
close the Mosaic tool.

188

Exploring ENVI

Skills Check

Skills Check
At this point, you should feel comfortable:
Using the Mosaic tool
Adjusting the contrast of images

Self Test
1. In mosaicking, can you choose which image will be displayed on top?
2. For byte data what value do you use to make the non-data areas white?

Exploring ENVI

189