Professional Documents
Culture Documents
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.
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
iv
Exploring ENVI
Contents
Exploring ENVI
Introduction
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 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.
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.
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.
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.
Bold
All ENVI menu options, dialog buttons, dialog fields, other dialog options,
and values that you need to enter are bold.
Courier
Numbered Steps
Exploring ENVI
Chapter 1:
Exploring ENVI
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.
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.
Exploring ENVI
Fundamentals
Exploring ENVI
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.
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.
Exploring ENVI
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.
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
10
Exploring ENVI
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.
11
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.
12
Exploring ENVI
Exploring ENVI
13
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
you can also use the middle mouse button to perform a pan.
Experiment with
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
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
Exploring ENVI
15
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
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
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
at the top of the Portal. This starts Flicker. You can change the
or faster
buttons.
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
Exploring ENVI
19
Spectral Profiles
Overview window, any enhancements, zooming, rotating, or Portals that are displayed in the image window
are burned into the output image.
2. From the Output File drop-down list, select JPEG. Next click the File Select button
Select Output Filename dialog appears.
. The
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.
20
Exploring ENVI
ENVI Help
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.
Exploring ENVI
21
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.
22
Exploring ENVI
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.
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
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
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
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.
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
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.
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.
28
Exploring ENVI
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.
Exploring ENVI
29
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
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.
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
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
Exploring ENVI
33
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
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
Skills Check
or
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:
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
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.
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.
38
Exploring ENVI
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
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.
40
Exploring ENVI
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
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.
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).
42
Exploring ENVI
Color Tables
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
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).
44
Exploring ENVI
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.
Exploring ENVI
45
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
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
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
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.
ENVI 5.0
Associated Data
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.
50
Exploring ENVI
Preprocessing
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.
Exploring ENVI
51
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.
52
Exploring ENVI
Dark Subtraction
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.
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.
Exploring ENVI
53
Dark Subtraction
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.
54
Exploring ENVI
Dark Subtraction
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
Topographic Modeling
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.
56
Exploring ENVI
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.
Exploring ENVI
57
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
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.
Exploring ENVI
59
Building Masks
60
Exploring ENVI
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.
Exploring ENVI
61
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.
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.
Elevation
Mean NDVI
0.42
0.46
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
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.
Exploring ENVI
Mouse Button
Action
Left
Middle
Right
63
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
Exploring ENVI
65
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
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
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.
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.
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.
Exploring ENVI
71
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.
72
Exploring ENVI
Vector Layers
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
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.
74
Exploring ENVI
Vector Layers
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
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
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.
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:
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
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.
ENVI 5.0
Associated Data
80
Exploring ENVI
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
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
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.
Exploring ENVI
83
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.
Exploring ENVI
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
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
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
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
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.
Exploring ENVI
89
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
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
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.
92
Exploring ENVI
Exploring ENVI
93
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.
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
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
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
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
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.
98
Exploring ENVI
Exploring ENVI
99
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.
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
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
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.
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
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
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
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
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
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
Exploring ENVI
109
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.
ENVI 5.0
Associated Data
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.
110
Exploring ENVI
Introduction
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
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
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?
Exploring ENVI
113
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
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:
Exploring ENVI
117
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.
ENVI 5.0
Associated Data
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.
118
Exploring ENVI
Sequential Maximum Angle Convex Cone (SMACC) Spectral Libraries and Hyperspectral Processing Tools
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.
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
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
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.
124
Exploring ENVI
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.
Exploring ENVI
125
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
Exploring ENVI
127
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
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
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
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.
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
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.
Exploring ENVI
135
Extending ENVI
136
Exploring ENVI
Extending ENVI
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
138
Exploring ENVI
Extending ENVI
Wolf (2010) recommends the use of the following indices for WV-2 data:
= NDWI (Water)
= NDVI (Vegetation)
= NDSI (Soil)
Exploring ENVI
139
Extending ENVI
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
140
Exploring ENVI
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)
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
Spectral Math dialog. In this example, we will mix spectra by combining several known endmembers.
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
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
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
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.
Exploring ENVI
145
Extending ENVI
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
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
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.
148
Exploring 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.
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).
Exploring ENVI
149
Extending ENVI
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.
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.
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.
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.
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.
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.
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.
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
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
to look
15. When finished, right click on View and select Remove All Layers.
16. Minimize the IDL Workbench.
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:
Exploring ENVI
163
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.
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
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.
Exploring ENVI
165
Color Transforms
166
Exploring ENVI
Color Transforms
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
168
Exploring ENVI
Exploring ENVI
169
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.
170
Exploring ENVI
Skills Check
Skills Check
At this point, you should know how to:
Enhance color-composite images with a saturation stretch
Exploring ENVI
171
Self Test
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.
ENVI 5.0
ENVI EX/FX license to run Feature Extraction
Associated Data
174
Exploring ENVI
Feature Extraction
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
176
Exploring ENVI
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
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 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
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
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
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
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.
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.
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