In this section we provide a demonstration of supervised classification of snow, glacier, vegetation and rock landcover classes. We use a Landsat TM image of a snow-covered glacier region of the Oeztal in the Austrian Alps. This image was acquired over the Hintereisferner and Kesselwandferner (glaciers) on August 24, 1989 [courtesy of Helmut Rott, University of Innsbruck, Austria]. A color composite of this image is show in Figure 7.1
The images for this section are located in ipwdemo/classify. Familiarize yourself with the image by displaying a "slide show" of the different spectral bands sequentially.
% xv *.ipw
or for accessing the images through hypertext links,
% xv 1.ipw 2.ipw 3.ipw 4.ipw 5.ipw 6.ipw 7.ipw
As each image is displayed, note the title, type H in the display to view a histogram equalization contrast stretch. Press the space bar (or the Next button in the xv controls window) to see the next image.
As described in Part 1, statistical measures of divergence can be used to determine the optimum bands for classification. Based on these measures, and previous research results, we have selected bands 2, 4 and 5 for use in this classification. Frequently the optimum bands for classification are not the same bands for best viewing the image.
Make directories for snow, glacier, vegetation and rock training sites
% mkdir rock veg glacier snow
Display a "true color" version of the Landsat TM scene. This scene was constructed by displaying band 3 as red, band 2 as green and band 1 as blue, and enhancing its appearance with the xv color editor. More information on creating color composites such as this is given in Appendix 4.
In the image green areas are vegetation, light-grey to blue-grey areas represent glacier ice, either bare or with thin snow, lilac and white areas are coarse-grained and new snow repectively, dark grey areas represent rock, and buff-colored areas are moraines and talus.
Open the xv coords window, and enter a coords file name.
Use the xv polygon command in fill mode to draw a polygon around an area of snow in the image.
Repeat this procedure for glacier, vegetation and rock training sites, using the coords file names glacier/coords, veg/coords and rock/coords. If you make a mistake outlining a training site, give the same file name and it will be overwritten.
You can designate more than one training site per category by numerically labeling the second, third, etc. polygons representing each additional training site. This is done using the label function described previously in the xv2.21 section or xv3.10 section. However, we suggest that you use one site for each category for your first try.
In this section, we introduce another advanced csh concept, the {} syntax We have shown the commands explicitly, however, if you are unfamiliar with this aspect of csh and want more information consult Appendix 3.
% merge {rock,veg,glacier,snow}/coords > coords
The order of these classes will define the output DN values used by mstats and bayes, since merge sequentially numbers the arguments in { }. That is, rock = DN 1, veg = DN 2, glacier = DN 3, and snow = DN 4.
The training sites cannot be redrawn on the color image 321.gif, due to the image format but they can be drawn on one of the raw image bands, or on a similar color image produced by a less optimal coloring method.
% scribe -i 2.ipw -c coords | xv
or
% scribe -i 321.col -c coords | xv -col
As described in the masking section, the following command will create a blank image.
% blank < 2.ipw > blank.ipw
% foreach class (rock veg glacier snow)
? scribe -f -c $class/coords -i blank.ipw > $class/mask.ipw
? end
The following command uses a nested foreach loop to generate 12 histograms.
% foreach class (rock veg glacier snow)
? foreach band (2 4 5)
? hist -m $class/mask.ipw $band.ipw > $class/$band.hst
? end
? end
You may plot training site histograms individually using xhist. For example, the following command will plot the histogram of band 1 for the snow training site.
% xhist snow/2.hst
Since it would be time consuming to plot 12 histograms like this, there is a command to plot all the histograms at once, into a postscript file. The postscript file can be viewed using xv 3.10, or ghostview, or it may be printed on a postscript printer.
% pscohist -I snow,glacier,veg,rock 2 4 5
Verify that the histograms approximate a normal distribution. if not, reselect a training site for that category.
Use the merged file from step 3 above to create the combined mask.
% scribe -f -c coords -i blank.ipw > mask.ipw
If you display this mask, it will initially be displayed as black. Type H in the xv display window to get a greyscale representation, (histogram equalization) or use the xv color editor to change the display colors of each training site.
The following command will compute the statistics.
% mux {2,4,5}.ipw | mstats -c mask.ipw > stats
The following command runs the Bayesian classifier, using the three image channels, and statistics file as input. The output is the classified image.
% mux {2,4,5}.ipw | bayes -s stats > bayes.ipw
Display the classified image
% xv bayes.ipw
Note that the image will come up all black. Type H for a greyscale representation. You will now have a four-value image; black will be rock, dark grey will be vegetation, light grey will be glacier and the white areas will be the snow class. You can also use the xv color editor to create a color image. An example of the type of output that can be achieved is shown in figure 7.2 A schematic representation of the supervised classification process is shown in Flowchart 4.