Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  Using ENVI  >  Image Change Tutorial

ENVI

Image Change Tutorial

Image Change Detection Tutorial

In this tutorial, you will learn different methods for detecting spectral changes in multispectral imagery, before and after a flooding event. You will use the Image Change Workflow to create a greyscale image of the flood extent, based on a principal components analysis (PCA) transform. You will create a difference image that highlights where the most significant changes occurred. You will threshold and smooth the difference image before exporting it to a classification image and shapefile. Finally, you will evaluate the results.

See the following sections:

Files Used in this Tutorial


Tutorial files are available from our website or on the ENVI Resource DVD in the Sentinel\S2A_MalaRiver directory.

File

Description

MalaRiver_2017-02-20.dat

Sentinel-2 layer-stacked image subset from 02 February 2017. This is the "Time 1" image that was acquired before a flooding event in Peru.

MalaRiver_2017-03-12.dat

Sentinel-2 layer-stacked image subset from 12 March 2017. This is the "Time 2" image that was acquired after a flooding event.

Sentinel-2 Level-1C source images were downloaded from the U.S. Geological Survey (USGS) EarthExplorer web site. See the Earth Resources Observation and Science (EROS) Center web site for more information about the USGS distribution of Sentinel-2 products. Pixel values represent top-of-atmosphere (TOA) reflectance. The source images were already co-registered, and they have the same number of rows and columns.

Additional processing steps were taken to create each file listed above:

  • Combined the 10-meter, 20-meter, and 60-meter band groups into one image using the Layer Stacking tool. The 20-meter and 60-meter bands were up-sampled to 10 meters.
  • Created a spatial subset around the area of interest.
  • Used the Edit ENVI Header tool to change the band names and to set the data-ignore value to 0.

Reference: "Level-1C Algorithm." Sentinel-2 MSI Technical Guide. https://sentinel.esa.int/web/sentinel/technical-guides/sentinel-2-msi/level-1c/algorithm (accessed March 2018).

Acknowledgement: These files contain modified Copernicus Sentinel data (2017).

Background


In early 2017, an El Niño event caused sea surface temperatures to rise in the Pacific Ocean, off the coast of Peru. This resulted in heavy, persistent rains that produced landslides and floods throughout Peru. Rain that fell west of the Andes mountains caused massive river flooding and property damage in coastal communities. One affected area was the Mala District south of Lima. The Mala River, which originates in the Andes, overflowed its banks. Although several areas were impacted by river flooding, the Mala River was chosen as a study site for this tutorial because of the availability of cloud-free Sentinel-2 imagery in the region, before and after flooding.

The following image shows the geographic coverage of the images used in this tutorial:

Open and View Images


Follow these steps:

  1. Start ENVI.
  2. From the menu bar, select Views > Two Vertical Views. Two adjacent, empty views appear in the display. A cyan-colored border surrounds the left view, to indicate that it is the currently selected view.
  3. From the menu bar, select File > Open.
  4. Navigate to the location where you saved the tutorial data, and select the file MalaRiver_2017-02-20.dat. Click Open. The pre-flood image appears in the left view.
  5. From the Stretch Type drop-down list in the toolbar, select Linear 1% to brighten the image.
  6. Click inside of the empty view on the right side to select it.
  7. From the menu bar, select File > Open.
  8. Select the file MalaRiver_2017-03-12.dat. Click Open. The post-flood image appears in the right view.
  9. From the Stretch Type drop-down list in the toolbar, select Linear 1% to brighten the post-flood image.
  10. Click the Data Manager button in the toolbar. The Data Manager lists the bands that comprise each image, along with their center wavelengths (in nanometers); for example:
  11. Next, you will link the views by geographic location. From the menu bar, select Views > Link Views. The Link Views dialog appears. The Geo Link radio button is selected by default.
  12. Click the Link All button.
  13. Click OK.
  14. Use the Pan and zoom tools (in the toolbar) to explore the before-and-after images. Because the views are linked, they move simultaneously as you pan and zoom. Notice the extent of the flood damage in the March 12 image:

You can partially assess the flooding extent from looking at a true-color image such as this one. To more accurately map the changes that occurred from flooding, you can perform an image change detection analysis. The following sections describe different options for detecting changes between two images based on their spectral information. The result is called a difference image.

Use an Image Transform for Change Detection


In this section you will use the Image Change Workflow to create a difference image based on a principal components analysis (PCA) transform. PCA is one method used to extract image features that correlate to change.

  1. In the Toolbox, expand the Change Detection folder and double-click Image Change Workflow. The File Selection panel appears.
  2. Click the Browse button next to Time 1 File and select MalaRiver_2017-02-20.dat.
  3. Click the Browse button next to Time 2 File and select MalaRiver_2017-03-12.dat.
  4. Click Next in the File Selection panel to proceed to the Image Registration panel.
  5. Because the images are already co-registered, you can keep the default selection of Skip Image Registration.
  6. Click Next to proceed to the Change Method Choice panel.
  7. Select the Image Transform option.
  8. Click Next to proceed to the Transform Method Choice panel.
  9. Keep the default selection of PCA for Transform Method Choice.
  10. Click Next to run PCA transforms on the images. The workflow proceeds to the Band Choice panel.
  11. The Band Choice step lets you choose the PC band that best highlights differences in the feature you are interested in. Band 1 is selected by default, and a preview of PC band 1 is displayed. Select different bands from the drop-down list to preview the results. Notice how Bands 1 through 6 contain useful image information, while the remaining bands contain mostly noise.
  12. Select Band 3 from the drop-down list. This PC band effectively highlights the changes that occurred from flooding between the Time 1 and Time 2 images.
  13. Click Next to proceed to the Export panel.
  14. Keep the default selection of ENVI for the output file format.
  15. Click the Browse button next to Output Filename. Choose an output folder and name the output image file PCA_Band3_ImageDifference.dat.
  16. Click Save.
  17. Click Finish in the Export panel. When processing is complete, the greyscale difference image is displayed in the second view. Brighter pixels correspond to areas with the most significant changes between the two dates.
  18. The Layer Manager lists the difference image above the true-color image from March 12. Click the checkbox for PCA_Band2_ImageDifference.daton and off to toggle between the two images.

Next you will create another difference image by subtracting the same bands from both images.

Use an Image Band Difference for Change Detection


In this section, you will use the Image Change Workflow to perform an image band difference technique. The difference image created from this will highlight the differences, or changes, that occurred in the selected band between two dates. You can apply a threshold to the difference image, then clean up the result and save it as a classification image or shapefile.

Configure the View

You will be using a single view in this section. Follow these steps to configure the view:

  1. In the Layer Manager, select MalaRiver_2017-02-20.dat in the first view. Then drag it to the View label in the second view. This copies the February 20 (Time 1) image to the second view.
  2. Select the second view to make it the current view. You can do this by selecting the second View label in the Layer Manager or by clicking inside the second view within the image display.
  3. From the ENVI menu bar, select Views > One View. This takes the layers from the second view and creates a single view with them.
  4. In the Layer Manager, click and drag MalaRiver_2017-03-12.dat above the other layers. The layer order should be as follows:

Evaluate Image Band Differences

  1. In the Toolbox, expand the Change Detection folder and double-click Image Change Workflow. The File Selection panel appears.
  2. Click the Browse button next to Time 1 File and select MalaRiver_2017-02-20.dat.
  3. Click the Browse button next to Time 2 File and select MalaRiver_2017-03-12.dat.
  4. Click Next in the File Selection panel to proceed to the Image Registration panel.
  5. Keep the default selection of Skip Image Registration, then click Next to proceed to the Change Method Choice panel.
  6. Keep the default selection of Image Difference, then click Next to proceed to the Image Difference panel.
  7. Keep the default selections of Difference of Input Band and Band 1.
  8. Enable the Preview option. A Preview window appears, showing the result of subtracting the first band of the Time 1 image (February 20) from the same band in the Time 2 image (March 12). The red areas indicate pixels that decreased in value over time, while the blue pixels indicate pixels that increased in value.
  9. Click and drag the Preview window around the display.
  10. The bands listed in the Select Input Band drop-down list are named Band 1 to Band 10. These correspond to the ten Sentinel-2 bands in the multispectral imagery, as the following table shows:

    Select Input Band List

    Sentinel-2 Band

    Band 1

    B2 Blue (496.6 nm)

    Band 2

    B3 Green (560.0 nm)

    Band 3

    B4 Red (664.5 nm)

    Band 4

    B5 Vegetation Red Edge (835.1 nm)

    Band 5

    B6 Vegetation Red Edge (703.9 nm)

    Band 6

    B7 Vegetation Red Edge (740.2 nm)

    Band 7

    B8 NIR (782.5 nm)

    Band 8

    B8A Narrow NIR (864.8 nm)

    Band 9

    B11 SWIR (1613.7 nm)

    Band 10

    B12 SWIR (2202.4 nm)

    Band 1 corresponds to the Sentinel-2 Blue band (B2), which is not sensitive to spectral changes in water. Floodwaters contain sediment and mud, which show up well in a shortwave-infrared (SWIR) band. You can use the B11 SWIR band for creating a difference image.

  11. Click the Select Input Band drop-down list and select Band 9. The Preview window updates to show the difference image for the B11 SWIR band.
  12. Floodwaters, wet soil, snow, and ice are features that appear dark in a SWIR image. These features absorb radiation in the SWIR wavelengths. When the difference is calculated for the SWIR band in the Time 1 and Time 2 images, the result is interpreted as a decrease in value. So the Preview window shows these features with a red color. Since the images in this tutorial do not contain any ice or snow, the red areas in the Preview window are mostly associated with mud and sediment-laden water.

  13. Click Next to proceed to the Thresholding or Export panel.

Apply Thresholding

Next you will apply a threshold to the difference image, to indicate how much detail you want to keep.

  1. Keep the default selection of Apply Thresholding, and click Next to proceed to the Change Thresholding panel. A Preview window shows a segmented representation of the difference image; for example:
  2. Click the Select Change of Interest drop-down list and choose Decrease Only. The Preview window updates to show red pixels only.
  3. The options listed in the Select Auto-Thresholding Method drop-down list are different methods for computing the threshold. Click the blue help button in the Image Change Workflow to learn more about each method. Keep the default selection of Otsu's.
  4. Click the Manual tab and experiment with different values for Decrease Threshold. Lower values mean a less restrictive threshold, which retains more detail in the difference image. A value of 750.0 works well in this example.
  5. Click Next to proceed to the Cleanup panel.

Clean Up the Image Change Results

The cleanup step refines the result. You can preview what the refinement will like look before you apply the settings.

  1. Keep the default selections for both cleanup methods:
    • Enable Smoothing removes speckling noise.
    • Enable Aggregation removes small regions.
  2. Enter values for the cleanup methods:
    • Specify the Smooth Kernel Size using an odd number (e.g., 5 = 5 x 5 pixels). The square kernel's center pixel will be replaced with the majority class value of the kernel. Change the value to 3.
    • Specify the Aggregate Minimum Size in pixels. Regions with a size of this value or smaller are aggregated to an adjacent, larger region. Keep the value at 100.
  3. Click Next to proceed to the Export panel.

Export Image Change Results

In the final step of the workflow, you will save the output from the analysis.

  1. In the Export Files tab, enable the check boxes for the exports:
    • Export Change Class Image saves the thresholding result to a raster file. Keep the default selection of ENVI for the output format, and name the output file MalaRiverChangeClassification.dat.
    • Export Change Class Vectors saves the vectors created during thresholding to a shapefile. Name the output file MalaRiverChangeClassification.shp.
  2. Click the Additional Export tab, and enable the check boxes for the remaining exports:

    • Export Change Class Statistics saves statistics on the thresholding image. Name the output file MalaRiverChangeStats.txt.
    • Export Difference Image saves the difference image to a raster file. Name the output file MalaRiverDifferenceImage.txt.
  3. Click Finish. ENVI creates the output, opens the layers in the Image window, and saves the files to the directory you specified.

Evaluate Results


Here is a summary of the data layers that are listed in the Layer Manager:

  • MalaRiverChangeClassification.shp: A shapefile with polygons of the thresholded image change results
  • MalaRiverChangeClassification.dat: A classification image of the thresholded image change results
  • MalaRiverDifferenceImage.dat: A difference image created by subtracting the SWIR band (B11) of the Time 1 image from that of the Time 2 image
  • MalaRiver_2017-03-12.dat: The Time 2 image
  • MalaRiver_2017-02-20.dat: The Time 1 image
  • PCA_Band3_ImageDifference.dat: The PCA difference image that you created earlier

Follow these steps to evaluate the results:

  1. Uncheck the MalaRiverChangeClassification.dat layer in the Layer Manager to hide it. The display currently shows the greyscale difference image that you just created, with the shapefile overlaying it. The vector polygons outline the areas of greatest change between the two input images, with regard to SWIR reflectance. They correspond to areas where muddy water increased after the flood event.
  2. Uncheck the MalaRiverChangeClassification.shp layer to hide it.
  3. Check the MalaRiverChangeClassification.dat layer to show it.
  4. Under the Classes folder, uncheck the following classes to hide them:
    • 0: Unclassified
    • 1: Other classes
    • 2: Big Increase

    Only the "Big Decrease" class is displayed (in red).

  5. Right-click on the Big Decrease class and select Edit Class Names and Colors. The Edit Class Names and Colors dialog appears.
  6. Select Big Decrease in the Class Names list, and change its name to Flood Impact. Press the Enter key.
  7. Click OK in the Edit Class Names and Colors dialog.
  8. Note: You may need to repeat Step 4 to hide the unnecessary classes.

  9. Uncheck the MalaRiverDifferenceImage.dat image to hide it. The "Flood Impact " class is displayed over the March 12 true-color image.
  10. Select the MalaRiverChangeClassification.dat layer in the Layer Manager (not the check box) to make it the active layer.
  11. Use the Transparency slider in the ENVI toolbar to adjust the transparency so that you can see through to the underlying image. The following figure shows the result with 50% transparency:
  12. Explore the classification image, along with the pre-flood and post-flood images. Does the "Flood Impact" class accurately outline the areas where new muddy water appeared after March 12?
  13. Right-click on the following layers in the Layer Manager and select Remove:
    • MalaRiverChangeClassification.dat
    • MalaRiverChangeClassification.shp
    • MalaRiver_2017-03-12.dat
    • MalaRiver_2017-02-20.dat
  14. Check the MalaRiverDifferenceImage.dat check box to show that layer. The SWIR difference image and the PCA difference image should be the only two layers displayed.
  15. Click the View Flicker button in the ENVI toolbar. The display flickers between the two difference images.
  16. Compare the difference images and assess whether they both identify the same areas of change.
  17. Move the cursor to the top of the display until a grey toolbar appears. Then click the and buttons as needed to slow down or speed up the flickering.
  18. To stop the flickering, click the View Flicker button again in the ENVI toolbar.

Tip: You can also achieve the same effect by checking and unchecking the MalaRiverDifferenceImage.dat layer in the Layer Manager.

This concludes the tutorial. For more information on Image Change Detection, refer to the ENVI Help.



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us