0% found this document useful (0 votes)
30 views21 pages

Principal Component Analysis in ENVI

The document outlines the procedure for performing Principal Component Analysis (PCA) using ENVI software, detailing steps from constructing an image cube to processing the data. It includes instructions for saving images, creating masks, and executing PCA, along with tips for managing file organization and display settings. The guide emphasizes the importance of correctly entering wavelength data and using the masking feature to exclude unwanted areas from analysis.

Uploaded by

Shelton Uamusse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views21 pages

Principal Component Analysis in ENVI

The document outlines the procedure for performing Principal Component Analysis (PCA) using ENVI software, detailing steps from constructing an image cube to processing the data. It includes instructions for saving images, creating masks, and executing PCA, along with tips for managing file organization and display settings. The guide emphasizes the importance of correctly entering wavelength data and using the masking feature to exclude unwanted areas from analysis.

Uploaded by

Shelton Uamusse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Principal Component Analysis in ENVI

Outline of Procedure: (I use ENVI v.4.5, but this demonstration, but expect it to be
identical/similar for v.4.7)
1. construct the image cube from the images. Note that the image cube is called a
“stack” in ImageJ;
1.1 read in all images to be included in the cube via
“File Æ Open Image File”;
You can (and should) select multiple files from the list.
1.2 Navigate to the directory where the images are stored and select all of them,
click the Open button in the lower right
1.3 The files show up in the “Available Bands List” and may be selected to
render an image, either a gray-scale image from one band or a (pseudo)color
image from three bands.

.
1.3.1 I often generate an approximate color image from the bands closest to
red (e.g., 625nm), green (535nm), and blue (450nm); for the systems
we typically use, these are band 8 for red, band 5 for green, and band 2
for blue. Note that you need to select the “Band” rather than the file
name.
1.3.2 The image shows up with three panes, (1) the “Scroll” window in the
lower left, which shows the full image, (2) the “Image” window (a
magnified view of the rectangular area outlined in red in the Scroll
window), and the “Zoom” window, which is a magnified view of the
selection outlined in red in the Image window. Note that you can
“click” and “drag” to change the sizes of the windows; I generally
enlarge the Scroll window so that I can see more detail over the full
page and it often is useful to enlarge the Image window for the same
reason, but you’re limited by screen real estate (which means that it is
helpful to have two monitors, one with the menus and one with the
images).
1.4 The next task is to save the images as an “Image Cube”
1.4.1 “File Æ Save File As Æ Envi Standard”

1.4.2 This pulls up the “New File Builder”


1.4.3 Click on “Import File”, this pulls up the “Create New File Input File”
window (seems like a weird name); you will see a list of ALL files
currently open in ENVI; select the files you wish. to include in the
image cube If you want all of the files on the list, click on the first
name and hold down the SHIFT key when clicking the last name
1.4.4 Click “OK”; this returns you to the “New File Builder” with the file
names in descending order (last file with longest wavelength first)
1.4.5 Now a trick – though the files are listed in descending order (last band
with longest wavelength first); we generally prefer the opposite order
with shortest wavelength first; there is nothing magic about this – it is
just convention. To reorder them, click the “Reorder Files” button to
get a list of files that you can rearrange. Rather than click and drag, the
trick is to use the “center” button on the mouse (it’s the wheel on my
mouse); click on that button while the mouse is hovering over the list
to reverse the order of files and then click “OK”
1.4.6 Click the “Choose” button after “Enter Output Filename”; select a
directory and file name; I use the same file name as the images, and I
generally put all of the ENVI cubes in the same directory (but this is
up to you)

1.4.7 After entering the name, click “OK” to return to the “New File
Builder” and “OK” again to save the file; this will take a few minutes
to “Create New File”
(a progress bar will give a rough estimate of how much time is required.)
You are now ALMOST ready to process the file; the last thing to do is to enter
the wavelengths in the file header, which is a separate file in the same
directory with the same file name but with suffix “.hdr”. You can do this
within ENVI, but I find it MUCH easier and quicker to use a text editor (I use
“TextPad”). When you open the text file; you will see something like the list
below:
---------------------------------------------------
ENVI
description = {
Create New File Result [Mon May 24 11:49:39 2010]}
samples = 7216
lines = 5412
bands = 12
header offset = 0
file type = ENVI Standard
data type = 12
interleave = bsq
sensor type = Unknown
byte order = 0
wavelength units = Unknown
----------------------------------------------------
Note that the wavelength unit in the original header file is listed as “unknown” and
that there are no numerical values attached. I created a dummy file with the units
and numerical values see below for REFLECTIVE wavelengths (will discuss
transmissive and raking cases immediately). The locations of the line breaks have
no effect on the file.
------------------------------------------------
wavelength units = nanometers
wavelength = {
365.000000, 450.000000, 465.000000, 505.000000,
535.000000, 592.000000,
625.000000, 638.000000, 730.000000, 780.000000,
850.000000, 940.000000}
-------------------------------------------------
I copy this dummy listing and paste into the header file to produce this:
---------------------------------------------------
ENVI
description = {
Create New File Result [Mon May 24 11:49:39 2010]}
samples = 7216
lines = 5412
bands = 12
header offset = 0
file type = ENVI Standard
data type = 12
interleave = bsq
sensor type = Unknown
byte order = 0
wavelength units = nanometers
wavelength = {
365.000000, 450.000000, 465.000000, 505.000000,
535.000000, 592.000000,
625.000000, 638.000000, 730.000000, 780.000000,
850.000000, 940.000000}
----------------------------------------------------
1.5 To my knowledge, ENVI can only handle numerical wavelengths, so I
created a different numbering scheme for transmissive wavelengths by
adding “1” to each wavelength; select a different numerical code for raking-
incidence illumination
TRANSMISSIVE WAVELENGTHS
------------------------------------------------
wavelength units = nanometers
wavelength = {
366.000000, 451.000000, 466.000000, 506.000000,
536.000000, 593.000000,
626.000000, 639.000000, 731.000000, 781.000000,
851.000000, 941.000000}
---------------------------------------------
1.6 Close the image cube file; I also suggest closing ALL image files to clean up
the space via File Æ “Close ALL Files”.
1.7 Reopen the image cube file via “File Æ Open Image File”; navigate to the
directory where the image cube is located and click on it. You should see a
list of bands with numerical wavelengths on the “Available Bands List” You
can again select a band for display as a monochrome image or select three
bands for display as RGB
2. Make the Mask: The goal here is to mask out areas to be excluded in the calculation
of the multispectral image statistics used to determine the axes of the principal
components. Anything outside the sheet of parchment or paper, (e.g., the MacBeth
color chart, any holes in the pageif they exist, etc.) should be excluded. I suggest
using the “Masking” capability of ENVI, which excludes selected regions while
maintaining the full image size – this means that pixels of the unprocessed and
processed images are always in register. Note that this is not possible in the current
versions of ImageJ.
2.1 Open the “Region of Interest” (ROI) tool via
“Basic Tools Æ Region of Interest Æ ROI Tool”
(Note that SOMETHING must be displayed to open ROI tool)
2.2 Various choices are available under “ROT_Type”, including “polygon”
(default) and “rectangle”. “Polygon” allows you to make masks with
irregular shapes to maneuver around holes, etc.
2.3 Click on “New Region”, which will show the color of the ROI, click on the
region number to highlight it; with polygon, click around the image in the
Scroll pane to create the ROI, right click to end the selection
2.4 To create the mask from the ROI, go to
“Basic Tools Æ Masking Æ Build Mask”

2.5 You will see the window to “Select Input Display” – select one of the
available displays (do NOT select “no display”), click “OK”
2.6 You will see the “Mask Definition” window
2.7 Click on “Options” Menu Æ “Import ROI”, select the region you want to
use:, click “OK”

2.8 You are now back at the “Mask Definition” window, select “Choose” under
“Enter Output Filename” and click “Apply” to create the mask window –
this will show up in the “Available Bands” List
3. PCA: Now that the mask is created, it is time to do PCA.
3.1 Go to
“Transform Æ Principal Components Æ Forward PCA Rotation Æ Compute new
statistics and rotate”

3.2 You will see the “Principal Components Input File” window
3.3 Select the input file (NOT the mask file), you will then see other options as
shown.

3.4 The FIRST thing I do is “Select Mask Band” – click on the button, select the
mask just created, and click “OK” – after you do this, there is no reason to
select a “Spatial Subset”
3.5 You may want to select a “Spectral Subset” – a subset of the bands. For
example, I always exclude the UV band if doing transmissive imaging, since
nothing seems to get through.

3.6 Once the mask and spectral bands are chosen, click “OK” to get the
“Forward PC Parameters” window
3.7 Lots of options here, but I suggest accepting the defaults for them. You do
need to choose the filenames (for which I use the same root names, as they
are distinguished by the suffix); Click on “Output Stats Filename” and type
in the name; I suggest something like: “DDC_682_p9_RF_02_” with a suffix
like “PCA_bands01-12”.
3.7.1 NOTE that the first time you do this, ENVI will default to its so-called
“Hook” directory under the ENVI program files – this just makes it
hard to find, so I put it in the same directory as the image cubes.
3.8 Select the Output Filename; I use the same root name, e.g.,
“DDC_682_p9_RF_02_PCA_bands01-12” and click “OK”
3.9 ENVI goes off on its merry way to calculate the PCA bands. This can take a
while depending on the number of bands and the size of the mask region: (1)
computes the statistics and (2) does the PCA band rotation. When it is
finished, you will get a new set of N bands on the “Available Bands List”,
which are the N PCA bands computed from the N input bands in order of
descending variance. You will also see a graphical display of the so-called
“eigenvalues” of the computation, which are (loosely speaking) the variances
of the N PCA bands.

Display after PCA calculation showing PC bands in “Available Bands List” and PC Eigenvalues graph
3.10 Before displaying the PCA bands, you need to turn off (hide) the region of
interest if you haven’t already done so. Click on “Hide ROIs” on the ROI
Tool; You may then select PC bands for display either one at a time with
Grayscale rendering or in groups for pseudocolor rendering. The largest
variance shows up in the first bands, so you may see some variations in
illumination in the first few bands. The last few bands should be dominated
by noise, which often includes the “split” in the center of the frame because
of the method for reading out the CCD image.
3.11 Again, you can display as individual monochrome bands or create a
pseudocolor from three bands as red, green, and blue bands. Note that you
can select the same band as a red, green, or blue to create pseudocolor
images.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy