PH330 Lab Exercise #2.

Introduction to ENVI: Image Processing using RADARSAT SAR data

URL:

http://www.geo.mtu.edu/great_lakes/icegroup/ph330/lab2.html

Drew Pilant Fisher 010B

anpilant@mtu.edu 487-2083

LARS: 614 M&M 487-3199

LARS system administrator: Chris Williams -3199

Geology system administrator: Mike Dolan -2167

Hello Remote Sensing o' Philes!

The objectives of PH330 Lab Exercise 2 are to:

- introduce you to the ENVI software;

- introduce you to image processing and interpretation of synthetic aperture radar (SAR) data;

- become more familiar with some useful UNIX commands.

The text that follows is somewhat modular, the main modules being:

- UNIX commands (xhost, rlogin, ypasswd, setenv, ps, ls, ln -s, grep, kill)

- generic ENVI concepts

- specific instructions for operating ENVI;

- miscellaneous.

Please don't hesitate to call or email me with questions and especially with problems.

-----------------------------------------------------------------

Beginning an ENVI session:

tephra.geo(7)% envi

or

tephra.geo(7)% envi_rt

NOTE: if you enter ENVI and find yourself in "7 minute demo mode", that means that neither of the two licenses are available. Quit the demo mode. Go into Command Line IDL, then type ENVI. If you still get stuck in demo mode, wait for a license as instructed, or if you are in LARS, look around and see if anyone is using/not using it.

After your ENVI session:

Be sure to "Quit" ENVI when done, as we need all the licenses. If you are unceremoniously ejected or ENVI hangs, try killing the process as follows:

tephra.geo(6)% ps | grep idl

5542 pts/0 S 0:00 grep idl

5465 pts/21 S 0:04 /local/mantle.geo/rsi/idl/bin/bin.solaris2/idl -rt=/loc

tephra.geo(7)% kill -9 5465

(ps: list active processes;

| grep idl : find those containing expression "idl";

kill -9 5465: kill IDL/ENVI immediately referenced via process id)

GENERIC ENVI comments:

- sometimes have to hit return and "Ok" to make function go.

- if ENVI hangs, try to kill the process as described below.

- ENVI hypertext help is under System >> ENVI Online Help.

-------------------------------------------------

UNIX miscellany:

Remote Logins:

You can rlogin from a remote machine, or go login in LARS (Laboratory of Atmospheric Remote Sensing) (phone -3199 to arrange to get in there (the doors are always locked). You will have faster connect and display if you go to LARS. Note that its almost impossible to rlogin in from and display to an xterminal (or 'xterm'). You need to be sitting on a networked Sun computer that has its own cpu.

Xterminals are recognized by having a login prompt with an xwindows background of some kind. Stand-alone computers have a 'console' login prompt, without the xwindows-style background. (PACES labs are xterminals, I believe.) (Another note on rlogin and ENVI. On my machine, some of the parameter text in the widget boxes does not display properly; the lower half is truncated. I'm able to work with it like this, but if its too problematic, please go to LARS.)

(Mouse conventions. The default for clicking is the left mouse button. Some functions also middle and right mouse buttons.

Remote Login Procedure (rlogin):

You will be rlogging into tephra.geo from your machine. "**" indicates Unix commands you must enter.

**your_machine% xhost tephra.geo.mtu.edu

tephra.geo.mtu.edu being added to access control list

(This says "let others display on my display device".)

**your_machine% rlogin tephra.geo.mtu.edu

Password:

(use your ss# the first time, then change your password using the

'yppasswd' command.)

Once your rlogin connection has been made, you will be in an xterm with a "tephra.geo" prompt. Its useful to fire up another xterm for executing unix commands while the other tephra xterm is locked up using ENVI. To do this, type

**tephra.geo(59)% xterm &

[1] 9474

This starts another xterm, and runs it in the background (&) so that the original xterm remains available for accepting commands.

(These notes and commands assume that you are in your tephra.geo home directory. If you are elsewhere, or I made a mistake, you may need to verify your path location and reference files accordingly.)

-------------------------------------------------

Task 1: Symbolically Link the SAR Image to Your Directory (5 pts)

The SAR image we will use is about 1 Mbyte in size (1030225 bytes) (an order of magnitude larger than Bill Gates first hard drive). We can save a lot of space if we 'link' the files to our own directories, rather than copying them. The Unix command is 'ln'. Once linked, you can use the file as if it was in your directory, though it actually resides elsewhere.

The Lab 2 data will be in the directory called ph330_lab2:

**tephra.geo(0)% ls ../ph330_lab2

970401_keweenaw.envi

(list the contents of ph330_lab2 directory.)

**tephra.geo(0)% ls -l ../ph330_lab2

-rw-r--r-- 1 ice 1030225 Oct 17 17:44 970401_keweenaw.envi

(list the contents and filesizes of ph330_lab2 directory.)

Link the data to your directory:

**tephra.geo(2)% ln -s ../ph330/ph330_lab2_keweenaw.envi .

If you do an ls in your directory, it shows the file with an @ symbol indicating that it is linked. Execute the "ls -l" command above to obtain the file size of the original data.

-----------------------------------------------------------

Task 2: Figure Out How Many Rows and Columns Are in the SAR Image (5 pts)

This is a common problem. Your buddy gives you some excellent imagery, but forgets to tell you the number of rows and columns in the image. You must be a detective because without a header on the data file, your software can't read the data. Your task is to determine the number of rows and columns in the image based on the file size. (This assumes that the image file contains only data, no header or trailer information.)

ENVI references the image file and header information separately. The image file is simply an n-dimensional array, consisting of x number of columns, y number of rows and n number of bands. It is in binary format. In this exercise, we are using only one band of data, typical of radar data, so the image file is a 1-dimensional array of y-rows and x-columns. The header file (filename.hdr) is an ascii file containing 'header' information such as y and x (row, column) dimensions, interleave format, etc. You will create a header file for the file of interest. ENVI will prompt you, but you need to know the x-y dimensions. You will compute this. Note that I didn't give you the x-y dimensions, but I do tell you that the file is square. But knowing that it is square, and that these are 8 bit data (as opposed to 16 bit or 10 bit or ??), you can do the math. Type

**tephra.geo(4)% ls -l ../ph330_lab2/970401_keweenaw.envi

-rw-r--r-- 1 ice 1030225 Oct 17 17:44 970401_keweenaw.envi

1030225 is the file size in bytes. Now what? Well, if you were very intuitive and extremely lucky, you might be able to factor this into its correct x-y row-column dimensions. Fortunately, we have more info. In this operating system (Sun-Solaris) (and in most o.s.), 1 byte= 8 bits. We know, or we guess, that this is 8-bit data (i.e., the digital number (DN) representing backscatter intensity of each pixel is an integer value between 0-255, that is, between 0 and 2^^8). Therefore, each byte in this file is one datum, or one pixel. (16 bit data would be 2 bytes each.) Therefore this image consists of 1030225 pixels, in some unknown combination of rows and columns. Now all we have to do is find the row-column factors that multiply to yield a product of 1030225 bytes. Hint: the image is square. Take the square root of the total file size in bytes; the result is the number of pixels in each row and column. (Type 'xcalc' in an xterm to bring up a calculator.)

-----------------------------------------------------------

Task 3: Create a Header File and Ingest an Image File (5 pts)

From the ENVI Main Menu go to File >> Open Image File.

The "Enter Data Filename" dialogue widget appears. Go to the ph330_lab2 directory by clicking on "../" (the directory above), then click on "ph330_lab2". Click on the file of interest (subset.envi) or enter it in the "Selection" widget. The "Header Info" widget will appear. Enter the necessary information. (Samples (columns) = your result. Lines (rows) = your result. Bands = 1. Data type should correctly default to Byte. Hit OK when done. You have now created a file called 970401_keweenaw.envi.hdr (i.e., ENVI created a header file with the same name as the data file, with an appended ".hdr" suffix).

The "Available Bands List" widget appears.

Good job. You have created a header file and ingested an image.

-----------------------------------------------------------

Task 4: Display an Image (5 pts)

Go to the "Available Bands List" widget. Click on 970401_keweenaw.envi to highlight it, then click on "Load Band" to

display it.

Three windows appear. The large window is the "Image" window. The small windows are the "Scroll" window which shows the location of the subset in the Image window, and the "Zoom" window. The red box in the Scroll window shows the location of the subset displayed in the Image window. The red box in the Image window is the position of the Zoom window. Move it by clicking and dragging.

Cruise around! Check it out!

-----------------------------------------------------------

Task 5: Create a Subset Image of More Manageable Size (5 pts)

Processing goes much faster for smaller images than large.

Go Utilities >> File Utilities >> Create New File >> Standard File . The New File Builder widget appears. Go Import ENVI File and click on 970401_keweenaw.envi . The Create New File Input File widget appears. Click on Spatial Subset. In the resultant Spatial Subset widget, click on Subset by Image. The Subset Function widget appears. A red box circumscribes the image and can by resized by clicking-dragging from the corner, and moved by clicking dragging in the middle. Enter 400 in the Samples and Lines boxes. Click-drag the red box to the far upper right corner of the window. This is the subset you will create. Hit OK, then OK in the Spatial Subset widget, then OK in the Create New File Input File widget. The New File Builder widget appears. Type "subset.envi" in the Enter Output Filename box, then OK.

-----------------------------------------------------------

Task 6: Contrast Enhancement- Stretching the Digital Numbers to Highlight Features of Interest (5 pts)

We can adjust the distribution of brightness in the image to highlight features of interest. Histograms of scene DN help you understand the statistics of the your image.

Click right mouse button (b3) inside the Image window. A blue "Functions" box should appear in the upper left corner of the Image window. This box is full of functions (some of which are also available on the Main Menu.)

Go to Functions >> Contrast Enhancement >> Interactive Stretching

A contrast stretch tool box appears. The left of the two curves is the Input_Histogram of the backscatter intensity values in either the Scroll, Image or Zoom box (go to Histogram_Source to determine which). The histogram reports the number (y-axis) of pixels with a given brightness (digital number, DN; x-axis). The Input_Histogram also indicates the type of stretch used (Linear, Gaussian, etc.). The numbers along the x-axis are the image digital numbers (0-255). The numbers in boxes next to the red and green lines show the values between which the data are stretched (using the default, they are the same).

Stretch_Type and Histogram_Source are perhaps the most immediately useful tools; experiment with them. Go to Histogram Source and select Zoom. Observe how the Input_Histogram changes as you change the Historam_Source between Image, Zoom and Scroll (you are changing the sample population). Most importantly, observe how the histogram changes as you reposition the red zoom selection box over land, ice and water (while Histogram_Source is set to Zoom).

Question 4. Select Histogram_Source >> Scroll. The input histogram will appear as a two-humped distribution of digital numbers. Based on your observations of the distribution of backscatter intensity (distribution of grey values in the image), to which hump would you assign each of the three landscape classes (land, water ice)? Draw a rough sketch of the Input Histogram, and annotate the humps appropriately with land, water and ice.

-----------------------------------------------------------

Task 7: Output a JPEG Image (5 pts)

ENVI can conveniently output image files in various formats. JPEGs are handy because they are space efficient (they use a data compression scheme).

Check your current output directory. Go to Main Menu, File >> Change Output Directory. The Change Ouput Directory widget appears. Hit Choose. The Select Directory widget appears. If the Path box at the top shows the correct directory (your home directory on tephra.geo), hit OK. Otherwise, find your home directory, most likely by hitting "../" in the Subdirectories box and clicking on your home directory in the resultant list. Once you find it, hit OK. Then hit OK in the Change Output Directory widget.

In the Image window go to Functions >> Output Display >> JPEG. The Display JPEG File Parameters widget appears. Hit Choose in the Output JPEG File box. The Output Filename widget appears. Replace the text in the Selection box with "subset.jpg". Hit OK. Hit OK in the Display JPEG File Parameters widget.

This writes a file called "subset.jpg" to your working directory (in this case, your home directory on tephra.geo). To check if it came out ok, you can display it using the xv software. Go to the extra xterm you created above. Be sure that you have done the "setenv DISPLAY your_machine:0.0" command so that it will display to whatever computer you are sitting in front of. Type

tephra.geo(16)% xv subset.jpg &

In a few moments, the JPEG image will display on your machine. If you want to manipulate it, hit the right mouse button in the image to bring up the "xv controls" widget.

-----------------------------------------------------------

Task 8: Convolution- Median Filter for Smoothing Speckle and Dynamic Overlay for Image Comparison (5 pts)

Speckle is the salt-and-pepper appearance characteristic of SAR imagery. It results from coherent addition of waves from independent scatterers within the radar footprint. If it interferes with the analysis, it may be treated with various neighborhood averaging filters. By linking two displays, we can compare the results of our filtering operation with the original image.

Go Filters >> Convolutions >> Median.

Select subset.envi from the Convolution Input File widget.

Full Scene or Spatial Subset?

>> Full Scene. Hit OK.

In the Convolutions Parameters widget, hit Output Result to Memory, then OK. (You can save smaller images to memory, rather than writing them to a permanent file.)

In Available Bands List, hit New (for a new display), select the top file to display (Median(Band 1:subset.envi), then Load Band.

You now have a nice, median filter-smoothed image of the tip of the Keweenaw Peninsula.

Using the Available Bands widget, load subset.envi into Display 1, create a New Display, and then load the median filtered image into Display 2. Compare the median filtered version with the original. Note how the median filter makes the image blurrier, but that speckle is less distracting.

A more powerful way of comparing the images is as follows. Click the right mouse button in one of the Image windows to bring up the Functions box in the upper left corner of the Image window. Go Functions >> Link >> Link Displays. Go with the defaults and hit OK. Click the left mouse button on either of the images. A small window will appear under the cursor showing the same area from the other image. You can click-drag around do display other portions of the image. To enlarge the linked display area, click-drag the middle mouse button. You can clearly see what speckle is if you click on the median filtered image (Display 2).

Output a JPEG of the median filtered image, naming it "median.jpg".

Question 7: Is the spatial resolution the same between the two images? Please comment.

-----------------------------------------------------------

Task 9: Unsupervised Classification- Automated Image Segmentation Using Isodata the Alogorithm (5 pts)

Segmentation refers to lumping an image into feature classes. A particular landscape feature (e.g., hardwoods, rough ice, calm water) will tend to have a characteristic mean and variance of brightness values (this is essentially why our eye can distinguish among these feature classes). The Isodata algorithm used here examines the data set, defines n-number of hypothetical feature class means based on image statistics, then assigns each pixel to those classes based

on the DN of the pixel.

Go to Classification >> Unsupervised >> Isodata. Select subset.envi from the Classification Input File widget, hit OK. Hit Memory in the Enter Output Filename of the IsoData Parameters box, then OK. Open a New Display (Display 3) (Available Bands List widget, select the top item on the list (the item with the highest "M"emory integer, and hit Load Band.)

A color coded image should appear, dividing the scene into 5 classes. Go to Functions >> Link Displays. Unlink existing links, then create a new Linked Display between the median filtered image (Display 2) and the classified image.

Output a JPEG of the classified image, naming it "classified.jpg".

Question 8: Comment on the correspondence between the median filtered image and the classified image based on your visual comparison of the the two. Does it seem to be a good correspondence? Do any areas/features appear to be potentially misclassified?

-----------------------------------------------------------

Task 10: Color Tables: Exploiting Human Color Perception (5 pts)

Some features are easier to see if we apply color to the grey scale image. Boundaries tend to me more clear, but the meaning of the colors can be more confusing.

Go to your median filtered subset image. Go to Functions >> Color Mapping >> Envi Color Tables. Click on any of the color tables on the list and see what happens! The colored bar shows how the color assignments are made, ranging from DN=0 on the left to DN=255 on the right. (On some keyboards, you scan-click through the list using the up and down arrows.) Experiment with the Stretch Bottom and Stretch Top sliders. Set the color table to B-W Linear (black and white, linear stretch). Invert the color (make a negative) by sliding each slider to the opposite end. Does it enhance the detail in the ice? (You can do the same thing by going Functions >> Color Mapping >> Control RGB Planes. The RGB Channels widget appears. Go to Options >> Invert All Channels. Flip it back and forth. Observe how features become enhanced and subdued this way.

Find a color table that suits you, then export a JPEG image of it, naming it "color.jpg".

-----------------------------------------------------------

SAR Analysis questions (5 pts each) (these should be brief- no grand theses necessary):

A-1. In the original image (970401_keweenaw.envi), why are Houghton and Hancock bright? I.e., why are they brighter than the lake or surrounding forest?

A-2. Why are lakes such as Portage Lake and Twin Lakes relatively dark?

A-3. Why are the NE-SW trending basalt ridges on the north half of the Keweenaw relatively bright? (E.g., near Gratiot Lake, Lac Labelle, Lake Medora)

A-4. The radar look direction is from east to west. That is, the radar was somewhere east of the Keweenaw Peninsula when this image was acquired. Why is the western shore of Portage Lake brighter than the eastern shore?

A-5. Comment on something you find interesting or cool about this image. If you want to, export a JPEG called "cool.jpg" that shows your phenomenon of interest.