REDE 2.4
Program by Jonathan Greenberg
Property of the CSTARS Lab at the University of California, Davis.
Please ask for permission before distributing this script.
Introduction:
MATLAB function for performing red edge vegetation analyses on hyperspectral
datasets using a cubic polynomial interpolation. The function returns the wavelength
location of the red edge.
System Requirements:
This program needs quite a bit of memory, but you can modify this somewhat by
lowering the "maxPixelRead" value.
- Unix users: make sure you have enough swap space (talk to your sysadmin).
- Mac users: you'll want to turn virtual memory WAY up if you do not have
sufficient RAM, and then allocate more preferred memory for the application.
To do this, SINGLE click on the MATLAB application and hit Command-I ("Get
info" if you want to use the File menu). Older OSs will see the "Memory
requirements" dialog-- change the "Preferred Size" to a much
larger number, depending on your input filesize. Close the MATLAB info window
and boot the program. Newer OSs should click where it says "General Information"
and change it to "Memory". Follow the above steps for upping the
memory. For AVIRIS scenes I typically set this value for 500 or 600 megs.
Feel free to complain to Mathworks
about their decision to not support a MacOS X version of MATLAB if you get
frustrated with dealing with out-of-memory errors.
- Windows users: make sure you have enough virtual memory.
With enough memory, this can be fairly speedy, but if it starts
using virtual memory it can take awhile. Be patient. Go get some
coffee and come back later.
Instructions:
1. Unzip the file with your favorite decompressor-- Unix users
use "unzip [filename]", Macintosh users can use Stuffit
Expander and Windows users have a myriad of decompressors (usually
WinZip is the unzipper of choice).
2. Place the redEdge.m file in your MATLAB:Toolbox:local folder.
3. You will need to first create a list of the wavelengths in BAND order of
the sensor. A down-and-dirty way of doing this is to open the header of the
image file and copy and paste the wavelengths into a separate text file. Each
wavelength should be on a separate line. We used a text editor to search and
replace all the commas with returns. Remember that it is important that you
do NOT sort the wavelengths-- sensors like AVIRIS record data somewhat out of
order, but we account for this in the program and you will get errors if you
try to sort it.
Note: We have included several inWaveFiles:
- AVIRISwave.txt: AVIRIS bands
- HYMAPwave.txt: HYMAP bands
- ASDFRwave.txt: ASD FR Spectrometer bands.
4. The command to initiate the function is "feval('redEdge',inBipFile,byteOrder,dataType,inWaveFile,numPixels,header,minWave,maxWave,maxPixelRead,outBipFile)".
- inBipFile: the filename of the image to analyze in BIP format.
- byteOrder = this is the numerical format of the input file following ENVI
header standards with a modification to include text files. The following
lists the codes:
- 0 = Least Significant Byte First (DEC and MS-DOS)
- 1 = Most Significant Byte First (SUN,SGI,IBM,HP,DG)
- 99 = CSV (columns = samples, rows = bands)
- dataType: this follows the ENVI header style, where:
- 1 = 8-bit byte
- 2 = 16-bit signed integer
- 3 = 32-bit signed long integer
- inWaveFile: the unsorted list of wavelengths from the sensor (see step #3).
- numPixels: the number of pixels or samples in your input file. For images,
this is the number of samples x the number of lines.
- header: the header offset-- usually just 0. Once again... check the header.
- minWave and maxWave: minimum and maximum shoulders of the red edge -- determine
by looking at the data first, choose regions that contain a less noisy red
edge for best results. I have found that AVIRIS and HYMAP datasets usually
have a fairly clear red edge region.
- maxPixelRead: this was implemented as a memory management function to avoid
entering virtual memory by processing the data in chunks and appending the
output to a file instead of trying to load the entire image into memory and
then attempting to process it. Try a value around 2000. This is the maximum
number of pixels read into memory at a time.This currently does not matter
if you are using 'text' as your file format.
- outBipFile: the continuum removal output-- it will be the same number of
samples and lines in BIP format, 1 band, header offset = 0 and the data type
is double precision. If you choose 'text' as your input file type, the output
file will be a CSV file of 1 row and numPixels columns.
Change Log:
2.4
- Removed the inBipFileFormat argument and replaced it with improved byte
order and data type support.
- Attempted to use ENVI standard header arguments.
2.2:
- Removed samples and lines input argument and replaced it with numPixels
to allow for non-image datasets such as spectrometer outputs.
- Removed the bands argument (it is now automatically determined by the number
of bands in the inWaveFile).
- Added inBipFileFormat for better control over numerical formats
- Added the capability of importing CSV files (use inBipFileFormat = 'text'
to use this feature).
- Added the inWaveFile for the ASD FR Spectrometer ('ASDFRwave.txt').
- Added the inWaveFile for the HYMAP aerial sensor ('HYMAPwave.txt').
- Renamed the AVIRIS inWaveFile ('AVIRISwave.txt').
2.1: Added "maxpixelread" argument which reduces memory usage significantly.
2.0: Original release of the red edge by interpolation function.
Bugs:
- The inWaveFiles were created on a Macintosh, so it may be neccessary to
either convert them or recreate them from the headers if they do not work.
- In ENVI, try using Host(Intel) as the Byte Order when importing the output.
Contact:
Jonathan Greenberg, greenberg@ucdavis.edu.
The software on this page has been created by CSTARS members,
and may be freely downloaded by outside users. However, if you wish to distribute
or use the source code of these applications, please ask permission from the
author(s) first. The author, CSTARS and the University of California take no
responsibility for any damage this software may create.