LAB 8: Scatterplots Load an image from the web page and...

9
CEE 615: Digital Image Processing 1 Lab 08 Scatterplots LAB 8: Scatterplots Load an image from the web page and display. Most of this exercise can be done using any image; however, I suggest using the spot_xi image on the web page for Lab 8. Pre-selected regions of interest are specifically for the spot_xi image. Using 2-D Scatterplots Use 2-D scatterplots to interactively examine the structure of the multispectral data, i.e. how do the 2- band clusters relate to image properties (ground cover, land use, terrain, etc.). Note: 2-D Scatterplots use only the data in the Main Image window, so to view the scatterplot for the entire image, increase the size of the main image window until it displays the entire image. (The scroll image will disappear.) 1. Display the SPOT 4 image. It will be easiest to see the areas in the image that correspond to the regions of the scatterplot if you display a gray value image. A CIR image would be: R: Band 3, G: Band 2, B: Band 1. A true color image cannot be displayed since there is no Blue band. An image that LOOKS like true color can be displayed using; R: Band 1, G: Band 4, B: Band 2. 2. From the Display menu, select Tools > 2D scatterplots. 3. When the Scatter Plot Band Choice dialog appears, choose the X and Y axes for the scatter plot by clicking on the desired bands in the columns labeled "Choose Band X:" and "Choose Band Y." Choose Band1 and Band 2 for the X and Y axes, respectively. 4. Click "OK" to extract the two dimensional scatterplot from the two selected bands. 5. In order to make the plots comparable, change the scale for each axis to cover the range [0, 255]. In the Scatter Plot window select Options > Set X/Y Axis Ranges, set the ranges appropriately and select OK. 6. Repeat steps 2-5 to display 4 scatterplots: a. Band 1 vs. Band 2 b. Band 2 vs. Band 3 c. Band 3 vs. Band 4 d. Band 2 bs. Band 4 7. To color density slice the scatterplots, select Options > Density Slice in the scatter plot window. 8. Select a density lookup table (LUT) that appeals to you. Select Options > Select density lookup and make a selection.

Transcript of LAB 8: Scatterplots Load an image from the web page and...

Page 1: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 1 Lab 08 Scatterplots

LAB 8: Scatterplots Load an image from the web page and display. Most of this exercise can be done using any image; however, I suggest using the spot_xi image on the web page for Lab 8. Pre-selected regions of interest are specifically for the spot_xi image. Using 2-D Scatterplots Use 2-D scatterplots to interactively examine the structure of the multispectral data, i.e. how do the 2-band clusters relate to image properties (ground cover, land use, terrain, etc.). Note: 2-D Scatterplots use only the data in the Main Image window, so to view the scatterplot for the

entire image, increase the size of the main image window until it displays the entire image. (The scroll image will disappear.)

1. Display the SPOT 4 image. It will be easiest to see the areas in the image that correspond to the regions of the scatterplot if you display a gray value image. A CIR image would be: R: Band 3, G: Band 2, B: Band 1. A true color image cannot be displayed since there is no Blue band. An image that LOOKS like true color can be displayed using;

R: Band 1, G: Band 4, B: Band 2. 2. From the Display menu, select Tools > 2D scatterplots. 3. When the Scatter Plot Band Choice dialog appears, choose the X and Y axes for the scatter plot

by clicking on the desired bands in the columns labeled "Choose Band X:" and "Choose Band Y." Choose Band1 and Band 2 for the X and Y axes, respectively.

4. Click "OK" to extract the two dimensional scatterplot from the two selected bands. 5. In order to make the plots comparable, change the scale for each axis to cover the range [0, 255].

In the Scatter Plot window select Options > Set X/Y Axis Ranges, set the ranges appropriately and select OK.

6. Repeat steps 2-5 to display 4 scatterplots: a. Band 1 vs. Band 2 b. Band 2 vs. Band 3 c. Band 3 vs. Band 4 d. Band 2 bs. Band 4

7. To color density slice the scatterplots, select Options > Density Slice in the scatter plot window. 8. Select a density lookup table (LUT) that appeals to you. Select Options > Select density lookup

and make a selection.

Page 2: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 2 Lab 08 Scatterplots

Viewing Pixel Distribution of Scatter Plots Use Image Dancing PixelsTM to interactively view, in the image window, the distribution of points under a box drawn in the scatter plot. As the cursor moves, the spatial distribution of the corresponding pixels on the image changes accordingly.

1. Select Options > Scatter:Dance. 2. Change the class color to one that will contrast well with the image (e.g., yellow) by selecting

Class > Items 1:20 > Yellow in the Scatter Plot window. You will need to do this separately for each of the 4 scatter plots

2. Place the cursor anywhere inside the scatter plot and Press and hold the middle mouse button (or Ctrl + left on a 2-button mouse) while moving the cursor in the scatter plot. All pixels on the image that fall within the DN range of those selected in the scatter plot box are plotted in color in the Main Image window.

3. You may change the size of the box by selecting Options > Set Patch Size, changing the size of the box and selecting OK .

Viewing Pixel Distribution of Images Use Scatter Plot Dancing PixelsTM to interactively view, in the scatter plot, the distribution of the points that are in highlighted in the image window.

1. Select Options > Image:Dance. 2. Change the class color to provide good contrast in the scatterplot: Class > Items 1:20 > … 2. Place the cursor anywhere inside the Main Image window and click the left mouse button while

the scatter plot is displayed to mark pixels in color on the scatter plot. This shows the DN distribution of pixels falling within a spatial box the same size as that used in

the scatter plot (see Setting "Patch Sizes"). The box is not plotted on the Main Image display because of speed considerations.

scatter dance box

Page 3: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 3 Lab 08 Scatterplots

3. Press and hold the left mouse button while moving the cursor in the Main Image window to highlight the pixels in the scatter plot in real time as Dancing Pixels.

Zooming in Scatter Plots To zoom in on an area within a scatter plot (Note: this will change the x/y scale):

1. Select Options > Scatter:Zoom. 2. In the Scatter Plot window, click with the middle mouse button and drag the box outline that

appears. · To return to normal viewing, click in the Scatter Plot window with the middle mouse button.

Changing the Scatter Plot Density Distribution Color Table To change the color table used to define the density distribution colors:

1. Select Options > Select Density Lookup. 2. In the Select Density Lookup dialog, click on the desired color table name. The selected color table is applied automatically. (The default color table is "rainbow".) 3. Designate the number value of the color that will be used to represent the lowest values in the

scatter plot (color tables have 256 values) by clicking the "Scaling Floor" arrow increment buttons or by entering the value into the text box.

For color tables that have black on the lower end, setting a higher color value to represent the "lowest density" points in the scatter plot applies more visible colors (instead of black) to those points so that all points in the scatter plot are visible.

cursor position

scatter dance pixels

Page 4: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 4 Lab 08 Scatterplots

Drawing ROIs on Scatter Plots

ROIs can be drawn in the scatter plot to perform an interactive 2-band classification.

Drawing a Single ROI 1. In the Scatter Plot window, click the left mouse button at the vertices of a polygon enclosing the

desired region. 2. Use the right mouse button to close the polygon and complete the selection. When the region is closed, all pixels in the image that fall within the DN range of those selected

in the scatter plot are highlighted in color in the Main Image window.

Drawing Multiple ROIs or Classes 1. In the Scatter Plot window, select Class and select another color from the list. 2. Draw another ROI as described in the previous procedure. The corresponding pixels in the image are highlighted in the new color.

Editing Classes To remove pixels from an existing class:

1. In the Scatter Plot window, select Class > White. 2. Draw a polygon around the pixels to remove them. The deleted pixels return to the original scatterplot color.

Changing Class Colors Use the Class menu to change the color of the regions to be drawn in the scatter plot. Multiple ROIs or classes can be defined by selecting a new color for each class. The currently selected class corresponds with the color selected under the Class pulldown menu. (Note: There is no option for changing the color of a class that has already been defined.)

Deleting Classes To completely delete the selected class polygon, click the middle mouse button outside the scatter plot axes.

Perform an interactive 2-band classification

1. Choose the scatterplot in which the data cluster most distinctly. (I suggest using a density sliced scatterplot and a black & white image.)

2. Draw separate polygons around the distinct clusters and intervening areas, changing colors for each new region. Continue until most of the image is associated with one or another of the classes.

3. Display a "False Color" version of the image in a separate window and compare it to the "Classified image". Any surprises? Does the classification match what you would have done by visual interpretation?

Page 5: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 5 Lab 08 Scatterplots

4. Export the classes

You may export the highlighted image window pixels for the selected class color or for all of the classes to a standard ENVI ROI. You can then use the exported ROIs in other ENVI functions.

• To export a selected class, select Options > Export Class. If the ROI Controls window is on the screen, the region is listed as a "Scatter Plot Import." The class color and number of pixels in the region is also listed. The ROIs are retained in memory even when the ROI Controls window is not on screen. The Scatter Plot Import region will be listed in the ROI window the next time it is started.

• To export the highlighted image window pixels for all of the classes, select Options > Export All.

5. Import the ROIs to the other scatterplots.

• In another scatterplot select File > Import ROIs

• In the Import ROI window click on Select All Items. (You may also import one ROI at a time, or any subset of ROIs.)

6. Can you explain what's happening?

Calculate Mean Spectra To calculate the mean spectrum for the selected class or for all the defined classes: 1. Select Options > Mean Class or Options > Mean All. 2. When the Input File Associated with 2-D Scatter Plot dialog appears, select the corresponding

input file. The mean spectra are calculated and displayed in a plot window. 3. Try to relate these spectra to the scatter plots in terms of the separability of classes. Think about

looking at spectra to make the most effective choice of a subset of spectral bands.

Managing Scatter Plots Outputting Scatter Plots You can save scatter plot windows as PostScript files or image files (RGB binary file): BMP, HDF, JPEG, PICT, SRF, TIFF, or XWD files.

4.To save scatter plots, select File > Save Plot As > Postscript or Image File. For detailed instructions, see Display Output Options.

Page 6: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 6 Lab 08 Scatterplots

The n-dimensional Visualizer Spectra can be thought of as points in an n-dimensional scatterplot, where n is the number of bands. The n-D Visualizer is a projection of the n-D data onto a 2-D plane. It allows you to interactively rotate data in n-D space, select groups of pixels into classes, and collapse classes to make additional class selections easier. The selected classes can be exported to Regions of Interest (ROIs) and used as input into classification, unmixing or matched filtering techniques. The n-D Controls window provides the mechanism to select the bands to display, the methods (and speed) of rotation, and the tools to select classes. .

The n-D visualizer is designed to work with a subset of the image data − a ROI. One option is to export the ROIs that you have already selected directly into the n-D visualizer. To do this:

1) In the ROI Tool window, select File > Export ROIs to n-D Visualizer… 2) Select the image from which the data are to be displayed (SPOT_XI). 3) Select the ROIs that you wish to display 4) Select OK. The n-D Visualizer window and the n-D Control window appear. Both are dark. 5) Select the bands that you wish to display by clicking in the numbered boxes of the Control

window. As soon as two bands have been selected the data appear in the Visualizer window with those two bands as starting x-y axes.

6) Select Options > Show Axes to display the axes in the Visualizer window. Another option is to take a random sample of the image data for use with the n-D visualizer. To do this:

1) From the File men choose Generate Test Data. Make an image the same dimensions as the image (600x600 in this case), with uniformly distributed random numbers between zero and one. (Get the dimensions of the image by checking it's ENVI Header, select File > Edit ENVI Header in the Main menu, then select the image of interest.) a. Select File > Generate Test Data b. Select "Random (uniform) for the Output Image Value. c. Set the minimum value to zero and the maximum value to 1.

Page 7: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 7 Lab 08 Scatterplots

d. Set the Output Image Dimensions to match the size of the image you wish to explore (600x600 for the SPOT image).

e. Set the Output data Type to Floating Point. f. Set the Output Result to Memory. g. Click "OK".

2) Create the ROI. a. In the main image window, select Overlay > Region of Interest or Tools > Region of Interest. b. In the ROI Dialog, select Options > Band Threshold to ROI. c. Select the Random image and click OK. d. If you want approximately 25% of the image, then just set your band threshold range to zero-

0.25 (or some other equally sized range) e. Name the ROI, select a color and Click OK. (The points will appear as an overlay in the

image window.) f. Save the ROI to a file.

3) Select Spectral > n-Dimensional Visualizer > Visualize with New Data. The n-D Visualizer Input File dialog appears.

4) Select Spectral > n-Dimensional Visualizer > Visualize with New Data 5) Select the image (SPOT) file from which you wish to extract the n-dimensional scatter plots. 6) Click "OK" to open the file and start the function. The n-D Vizualizer Input ROI dialog appears. 7) In the n-D Vizualizer Input ROI, click on the ROI to be used in the n-Dimensional Visualizer. A status box appears while the ROI is loaded. After the ROI is loaded, the n-D Controls dialog

appears with the n-D Visualizer plot window.

General n-D Controls Dialog Functions After the ROI thresholded from the PPI image has been loaded, the n-D Controls dialog appears with the n-D Visualizer. The n-D Controls dialog contains representations of all of the bands that were selected during the file selection. The bands are represented by numbered boxes which initially appear black.

· Clicking on an individual box (band number) turns it white and toggles on display of the corresponding band pixel data in the n-D Visualizer as part of an n-dimensional scatterplot (at least 2 bands must be selected to view a scatterplot).

· Clicking again on the same box (band number) turns the box black again and toggles off the band data in the n-D scatterplot.

· Selecting two bands (by clicking on the associated numbered box) produces a 2-D scatterplot; clicking on three bands produces a 3-D scatterplot, etc.

Any number combination of bands may be selected at once.

Page 8: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 8 Lab 08 Scatterplots

Selecting Dimensions and Rotating Rotate data points by stepping between random projection views. You can control the speed and stop the rotation at any time. You can move forward and backward step-by step through the projection views, which allows you to step back to a desired projection view after passing it.

1. In the n-D Controls dialog, select bands (dimensions) for projection in the n-D Visualizer. Note - If you select only two dimensions, rotation is not possible.

If you select three dimensions, you have the option of "driving" the axes, or initiating automatic rotation. If you select more than three dimensions, only automatic random rotation is available.

2. Select from the following options: · To drive the axes, select Options > 3D:Drive Axes. Click and drag in the n-D Visualizer

window to manually spin the axes of the 3-D scatterplot. · To display the axes themselves, select Options > Axes:On. · To start or stop the rotation, click "Start" or "Stop." · To control the rotation speed, enter a value in the "Speed" text box, or use the arrow increment

buttons to increase or decrease the speed. Higher values cause faster rotation with fewer steps between views.

The information in the "View" status box tells you the number of steps you are moving through between the random projection views.

· To move step-by-step through the projection views, click the "<-" button to go backward and the "->" button to go forward.

· To display a new random projection view, click the "New" button.

n-D Visualizer Shortcut Menu Many options in the n-D Visualizer can also be accessed by right-clicking in the scatter plot and selecting from the shortcut menu that appears.

Defining Classes Typically, classes are defined where groups of pixels stay together during rotation and are separated from the rest of the pixels. Multiple classes can be defined at once.

1. Click the "Stop" button to stop the rotation when a group of pixels is isolated from the main body of pixels that are plotted in the n-D Visualizer. Or, use the arrow buttons to go to a particular projection view.

2. Highlight the desired pixels on the n-D Visualizer using standardized ENVI polygon selection procedures (left button to set a vertex, right mouse button to close the polygon).

· If a 3-D projection is selected, be sure to select Options > 3D: ROI Definition. 3. From the "Class" menu, select a color for the class.

· To automatically use the next available class color for the next ROI, select Class > New. 4. Click the "Start" button to rotate the scatterplot until additional groups of pixels are isolated and

repeat the class definition process.

Page 9: LAB 8: Scatterplots Load an image from the web page and ...ceeserver.cee.cornell.edu/wdp2/cee6150/Labs/Lab08... · Spectra can be thought of as points in an n-dimensional scatterplot,

CEE 615: Digital Image Processing 9 Lab 08 Scatterplots

Interacting with Classes Use the n-D Class Controls dialog to interact with individual classes. The number of points in each defined class and the class color are listed in the dialog. You can change the symbol used, turn individual classes on and off, and select classes to use when collapsing classes. You can also plot the minimum, maximum, mean, and standard deviation spectra for a class, plot the mean for a class alone, and /or plot all the spectra within a class. Also, you can clear a class and export a class to an ROI.

• In the n-D Controls dialog, select Options > Class Controls. All of the defined classes appear in the dialog. The white class contains all of the unclustered or unassigned points. The number of points in each class is shown in the text boxes next to the colored squares.

Turning Classes On/Off · To turn a class off in the n-D Visualizer window, click the "On" check box for that class. Click

again to turn it back on. · To turn all but one of the classes off in the n-D Visualizer window, double-click on the colored

box of the class that you want to remain displayed. Double click again to turn the other classes back on.

Selecting the Active Class · To designate a class as the active class, click on the colored square corresponding to that class. The color appears next to the "Active Class" label and any functions executed from the Class Controls dialog affect only that class. Note - A class may be selected as the active class even though it is not turned on in the n-D

Visualizer.

Changing Plot Symbols · To change the plot symbol for the active class, select the desired symbol from the "Symbol" button

menu.

Producing Spectral Plots To produce spectral plots for the active class:

1. Click the "Stats," "Mean," or "Plot" buttons. 2. When the file selection dialog appears, select the input file that you want to calculate the spectra

from. · If you select a file with different spatial dimensions than the file you used as input into the n-D

visualizer, enter the X and Y Offset values for the n-D subset when prompted. Note - If you select "Plot" for a class that contains hundreds of points, the spectra for all the points will

be plotted and the plot may be unreadable.

Clearing Classes · To remove all points from a class, click the "Clear" button.

Exporting Classes · To export the points to an ROI, click "Export."