This example shows how to explore hyperspectral data using the Hyperspectral Viewer app. Using the capabilities of the app, you can view the individual bands of a hyperspectral data set as grayscale images. You can also view color composite representations of the data set as RGB, color infrared (CIR), and false-color images. In addition to exploring these visual representations of the spatial dimensions of the data, you can create plots of individual points or small regions of the data along the spectral dimension. These plots, called spectral profiles, can identify elements in the hyperspectral data.
For this example, load an aerial hyperspectral data set of an area called Jasper Ridge, captured via the airborne visible/infrared imaging spectrometer (AVIRIS). The data set contains areas of water, land, road, and vegetation. Load the hyperspectral data set into a
hypercube object in the MATLAB® workspace.
hcube = hypercube('jasperRidge2_R198.img');
This command creates a
hypercube object in the workspace called
hcube object contains a 100-by-100-by-198 cube of hyperspectral data.
Open the Hyperspectral Viewer app. First, click the Apps tab on the MATLAB toolstrip. Then, in the Image Processing and Computer Vision section, click the Hyperspectral Viewer button.
With the app open, load the hyperspectral data into the app. On the app toolstrip, click Import and select Hypercube Object. In the Import from Workspace dialog box, select the
hypercube object you loaded into the workspace,
hcube. (You can also specify a data set when you open the app using the command:
The app displays several views of the Jasper Ridge hyperspectral data. The Bands pane displays the bands of the hyperspectral data as a stack of grayscale images. A second pane includes color composite representations of the hyperspectral data, displaying the False Color tab by default. The Plots pane displays a histogram of the band currently displayed in the Bands pane and a plot of the spectral dimension of the data by wavelength or by band. (You can rearrange these panes by clicking and dragging them inside the app. To return to the standard pane arrangement, click Default Layout on the app toolstrip.)
Explore the spectral bands of the Jasper Ridge data set as a stack of grayscale images in the Bands pane. Use the slider at the bottom of the pane to navigate through the images. Because each band isolates a specific range of wavelengths, aspects of the scene might be clearer in some bands than others.
To get a closer look at a band, click Zoom In or Zoom Out in the axes toolbar that appears when you point the cursor over the image.
To improve the contrast of a band image, click Adjust Contrast on the app toolstrip. When you do, the app overlays a contrast adjustment window on the histogram of the image, displayed in the Plot pane. To adjust the contrast, move the window over the histogram or resize the window by clicking and dragging the handles. The app adjusts the contrast using a technique called contrast stretching. In this process, pixel values below a specified value are displayed as black, pixel values above a specified value are displayed as white, and pixel values in between these two values are displayed as shades of gray. The result is a linear mapping of a subset of pixel values to the entire range of grays, from black to white, producing an image of higher contrast. To return to the default view, click Snap Data Range. To remove the contrast adjustment window from the histogram, click Adjust Contrast.
Explore the Jasper Ridge hyperspectral data as a color composite image. To create these color images, the Hyperspectral Viewer automatically chooses three of the bands in the hyperspectral dataset to use for the red, green, and blue channels of a color image. The choice of which bands the app uses depends on the type of color representation. The app supports three types of color composite renditions: False Color, RGB, and Color Infrared (CIR). It can be useful to view all of the color composite images because each one uses different bands and can highlight different spectral details, thus increasing the interpretability of the data.
By default, the app displays a false-color representation of the data. False-color composites visualize wavelengths that the human eye cannot see. The tab of the pane identifies the type of the color image, False Color, and the bands that the app used to form it, (104,100,146), in red-green-blue order. The app indicates in the Spectral Plot which bands were used. To change these band selections, click and drag the handle of the band indicator in the Spectral Plot. If you choose a different band, the app updates the text in the tab with the new bands and adds the word "Custom," such as, False Color-Custom.
To create the RGB color composite image, the app chooses bands in the visible part of the electromagnetic spectrum. The resulting composite image resembles what the human eye would observe naturally. For example, vegetation appears green and water is blue. While RGB composites can appear natural to our eyes, it can be difficult to distinguish subtle differences in features. Natural color images can be low in contrast.
To create the CIR color composite image, the app chooses red, green, and near-infrared wavelengths. Near infrared wavelengths are slightly longer than red, and they are outside of the range visible to the human eye.
After exploring the grayscale and color visualizations of the hyperspectral data, you can plot points or small regions of the data along the spectral dimension to create spectral profiles. You can plot a single pixel or a region up to 10-by-10 pixels square. Use the Neighborhood Size slider to specify the region size. When you select a region, the app uses the mean of all the pixels in the region when plotting the data. Plotting a region, rather than an individual pixel, can smooth out spectral profiles.
To create a spectral plot, click Add Spectral Plot on the app toolstrip, move the cursor over a visualization in the app, and click to select the point or region. You can make your selections on any of the visualizations provided by the app. Your choice of which visualization to use can depend on which one provides the best view of the particular feature of the data you are interested in. When you make a selection, the app puts a point icon at that position on all of the visualizations. To select additional points, click Add Spectral Plot and repeat the process. To delete a point, right-click the point and choose Delete Point from the pop-up menu. To delete all of the points you have selected, click Clear All on the app toolstrip.
For example, the following figure shows four points selected in each visualization, each point representing a particular type of data: water, vegetation, road, and land.
As you select each point, the app plots the data on the Spectral Plot, using a different color to identify each plot. By default, the Spectral Plot also includes a legend identifying the plot for each point. To toggle off inclusion of the legend, click Show Legend.