In this lab we will be learning various image processing techniques. We will preform pre-processing techniques using Landsat 8 data and apply some image enhancement techniques to improve the contrast and visual interpretability of the images. We will be examining a Landsat 8 image acquired of Lake Erie and the surrounding communities. In recent years, Lake Erie and neighboring Lake St Clair have experienced large harmful algae blooms (HABs) during the warm summer months. These toxic blooms impact overall water quality and drinking water for many of the residents of the surrounding communities. Runoff rich in nutrients from agricultural fields and warm weather contribute to increasing frequency and size of blooms.
We will be looking at Landsat 8 Operational Land Imager (OLI) and Thermal Infrared Sensor (TIRS) Level 1 Data in this lab. The data was acquired on August 4th, 2024 and focuses on western Lake Erie and the surrounding communities.
Learning Outcomes
Learn how to use the Radiometric Calibration Tool in ENVI to to calibrate original image data (DNs) to radiance, reflectance, or brightness temperatures.
Understand the concept of atmospheric correction and why it is important in remote sensing and learn to apply the Dark Object Subtraction correction technique.
Compare the results of pre-processing techniques using the Spectral Profile Tool.
Create and apply processing to data based on specific pixel values
Use the Color Table or Color Ramp tools to visualize single band data
Understand the importance of histograms and contrast stretching in image enhancement techniques.
Set up your Workspace
First we need to set up our workspace and transfer the data for the lab.
Create a folder on the Desktop named “Lab_08”.
Within the folder named “Lab_08”, create three sub folders as below:
Folder Structure (within Lab_08 folder):
Originals
Working
Final
Locate the GSP 216 Google Drive lab data folder and navigate to the Lab 08 folder. Locate the "tarball" (.tar.gz) file, this file is the original Landsat 8 Level-1 data file downloaded from EarthExplorer.
Use 7-ZIP to extract the Level-1 data into your Originals folder. See Lab 6: steps 13-15 for a review on how to extract "tarball" files.
Opening and Calibrating the Data
The below video goes over the Radiometric Calibration tool in ENVI. Note that this is an example dataset and will be different data than what is used in the lab.
We will start by opening the Level 1 Landsat 8 file of Lake Erie using the metadata text file. We will then walk through the process of radiometric calibration. The Radiometric Calibration tools is used to calibrate the original image data values ( or DNs) to radiance, reflectance, or brightness temperatures. ENVI does this by using the information provided in the metadata files. We will be calibrating the digital numbers to reflectance.
Start “ENVI (64-bit)” and Select File → Open and navigate to your Lab 8 Originals folder where you extracted your data. The Level 1 Landsat 8 data should be in this folder, select the metadata text file ending in "_MTL.txt" and click open.
You should now see a Landsat 8 image of Lake Erie in your viewer. The image may be quite dark, especially if there are clouds in the imagery. Use the Reference Map Link to explore and orient yourself to the geographic area of study. This image was acquired on August 2024.
Now we will calibrate the image data so the pixel values represent real-world units, in this case percent reflectance. From the Toolbox, select Radiometric Correction → Radiometric Calibration or type “radiometric” in the toolbox and the Radiometric Calibration tool will appear in the toolbox below. Open the Radiometric Calibration tool.
In the Radiometric Calibration window we need to select the Input Raster data for calibration. Click the three dots by the input and select the Landsat 8 multispectral image, it will end in "....._MTL_MultiSpectral" and click OK. This will radiometrically calibrate the seven reflective, multispectral bands of the Landsat 8 data.
In the Radiometric Calibration window select "Top of the Atmosphere (TOA) Reflectance" as the calibration type, change the Output Data Type to Uint and change the Scale Factor to 10000. This will multiply the data by 10,000 so we will have whole integers instead of decimals for our pixel values. Save the calibrated image in your Working folder as "TOA_Reflectance.dat". When the process is complete the calibrated image should automatically open.
Note: The "Scale Factor" setting is not always required and in some cases you may want to leave it set at 1. We are setting the scale factor to 10000 so the reflectance values for the Level 1 data. This is commonly done so the data are whole integers, as this reduces the file size. It is common for datasets to be scaled by 10,000. Note that a value of 10,000 represent 100% reflectance.
View Image Statistics and Histograms
Now we will calculate and view statistics for the image. Right click on the "TOA_Reflectance.dat" file in the Layer Manager and select "Quick Stats". A dialogue box will come up as ENVI calculates various statistics for the image. Once the calculations are complete the statistics view window will open.
The basic stats include the minimum, maximum and mean pixel values for each of the bands. Scroll down to see more detailed distribution statistics for each of the bands. Your values will differ from the values below, but should be similar magnitude. If they are drastically different (i.e. different magnitude), that is an indication that you made an error in the calibration process (radiance instead of reflectance, or incorrect scale factor).
For each band (seven in total) write down or copy/paste the minimum value, this is the lowest (non-zero) pixel value for that band. You can highlight the Band and associated Min value columns and copy them by selecting the Copy to Clipboard icon, then paste this information into a spreadsheet. We will use this information for our atmospheric correction process.
Now we will view the histograms for all of the bands. In the upper left hand corner click "Select Plot" and select "All Histograms". You should now see the histograms from all seven bands in the plot viewer. Select Options → Legend, this adds a legend for the seven different bands displayed on the histogram plot. The Y-axis is a count (the frequency or number of pixels with that particular value) and the X-axis displays the reflectance values. For example, if there is a large peak on the left hand side, that indicates that there are a lot of pixels with low reflectance values in that band of the image. Make note of the shape and distributions of the histograms. If you like, you can save the histogram by selecting Export → Image. Close the Statistics Window.
Atmospheric Correction (Dark Subtraction)
We will use the Dark Subtraction Tool to estimate and remove the effects of atmospheric scattering from the image by subtracting pixel values that represents a background scattering from each band. We will be using the band minimum
values we researched and wrote down in Step 11.
From the Toolbox, select Radiometric Correction → Dark Subtraction or type "Dark" in the Toolbox and open the Dark Subtraction Tool. The Dark Subtraction Input File window appears.
In the Dark Subtraction Input File dialog select the file "TOA_Reflectance.dat" and click OK.
The Dark Subtraction Values dialog appears, under Subtraction Method select "User Value". Click on each band (Bands 1-7) and enter in the minimum value you wrote down in Step 12. Once you have entered in a value for Band 1, click on Band 2 and enter in the appropriate value. Do this for all seven bands.
Once you have entered in the values for all seven bands name your output file "surface_reflectance.dat" and save it in your Lab 8 Final Folder. Click OK to start the Dark Subtraction process, it may take a minute or two to complete the process. The image should automatically open in your viewer. Use multiple views or the Blend, Flicker and Swipe view tools to visually compare the data layers. Make note of any differences (or lack there of) in appearance and contrast.
Contrast Stretch
Now we will improve the look of the atmospherically corrected image using the Contrast Stretch Tool, which is an image enhancement tool. ENVI automatically applies a contrast stretch to all images but you are free to change the contrast stretch at anytime. Learn More About the Stretch Types
You can control the contrast of layers individually. Make sure you have the "surface_reflectance" file selected in the Layer Manager. Locate Contrast Stretch drop-down in the main toolbar and try all of the different contrast stretches. If you are unhappy with the contrast stretch you can always click the "Reset Stretch Type" icon to restore the contrast to the default setting.
The Custom Contrast Stretch also allows you to apply custom contrast stretches using the histograms as a guide. This tool allows the
user to set the minimum and maximum value for each color channel (Red, Green, Blue) that the contrast stretch is applied to. Play around with the tool to see how the contrast and colors change as you move the minimum and maximum values. Click on the Red, Green and Blue histogram icons on the right hand side of the window to interactively stretch each band.
Experiment with the different contrast stretch types and select one (either custom or pre-set) that you think best highlights the algae blooms and surrounding area. Use the Chip View option (or snip/screenshot) to save a copy of the image to use in your report. Make note of what contrast stretch was applied and include this in the caption.
Compare the Reflectance Values and Spectral Profiles
Now we will compare the differences in the reflectance values in the two processed images: (1) The calibrated TOA Reflectance image ("TOA_Reflectance.dat"), and (2) the atmospherically corrected surface reflectance image ("surface_reflectance.dat"). To do this we will use the Spectral Profile Tool to plot the reflectance profiles of the same pixel in the two different images.
Make sure your have the "surface_reflectance" layer selected to start with. Click the Spectral Profile icon on the toolbar or select Display → Profiles → Spectral from the menu bar. This opens the Spectral Profile window.
In the Spectral Profile window click Options → Additional Profiles → Add File and select the "TOA_Reflectance.dat" and click OK. You should now see two spectral profiles in spectral profile plot. You should now see two spectral profiles, one for each of the processed files.
Explore the spectral profile of different pixel types (i.e. Water, Vegetation, Urban) by moving the cursor around the display window. Make note of any differences between the spectral profiles of the two different processed images.
Zoom in and use the cursor to select a water pixel to plot. Now we will add a legend to our plot. Select Options → Legend from the Spectral Profile menu bar. The legend should now appear in the profile plot.
Click the arrow on the right of the Spectral Profile window to show additional properties.
In the Curve tab, rename each of the profiles to:
Change "surface_reflectance".dat" to " Surface Reflectance"
Change "TOA_Reflectance.dat" to "TOA Reflectance" which stands for Top of Atmosphere Reflectance
You can also change the colors and look of the lines if you would like.
Now we will format the legend. In the properties window to the right of the profile plot select the third tab "Legend". Here you can change the legend style, font and size. Increase the font size of legend and the titles so they are clearly legible. Now rename the Y-axis as "Reflectance" by clicking the General tab under Y-Axis Title. In this tab you can also increase the font size of the axis labels.
Select "Export" → ASCII. This will save the data associated with the plot as a text file. You will need to use this data to create a table for your lab report (see Lab 3 steps 28-32 for how to import text into Excel). Save the spectral profile data (.txt) file in your Final folder. This text files lists the actual pixel values (reflectance) for each of the bands, for the images. Note that the pixel values have been scaled by 10,000, therefore a pixel value of 5,000 represents 50% reflectance and a pixel value of 10,000 represents 100% reflectance. Make sure this text file is saved in your folder before closing the plot.
Once you are finished with editing your spectral profile plot it's time to export the plot so you can insert it into your lab report. Select "Export" → "Image" from the Spectral Profile menu bar. Save your spectral plot in your Final folder as you will need this for your lab report. Make sure this image is saved in your folder before closing the plot.
Select Water Using ROI Threshold
Now we want to analyze the water and algae bloom, to do this we must create a Mask to isolate the water in the image. An easy way to create a water mask is to create a region of interest
(ROI) using the band-thresholded option. The band-threshold option allows you to select areas of an image based on specific values or ranges of values. Water has extremely low reflectance in the infrared regions. You can isolate those pixels with the ROI Tool by selecting areas with extremely low reflectance values in the near-infrared (NIR) band or Shortwave Infrared (SWIR) bands.
Landsat data products also include Quality Assessment (QA) bands to identify the pixels that exhibit adverse instrument, atmospheric, or surface conditions. This can include clouds, cloud shadows. This information can also be used to generate masks to exclude or isolate certain pixel types from analysis.
Right-click on the surface_reflectance.dat file in the Layer Manager, and select New Region of Interest. Name the ROI Water.
In the ROI Tool, click the Threshold tab. Click the Add New Threshold Rule button .
In the File Selection dialog, select the NIR band associated with the surface_reflectance.dat file and click OK. A histogram of the band is displayed in the Choose Threshold Parameters dialog.
You will identify the water pixels by selecting the range of low pixel values in the histogram. Water has very low reflectance in the IR, therefore areas with low reflectance should be water.
Click and drag the line on the edge of the plot toward the right, covering the data values from 0 to approximately ~500-900 (max value) or type in the Min and Max values above the histogram (exclude any negative values). Check the Preview option, the pixels that fall within this range are highlighted on the image in the color of the ROI. You will need to move the slider in the histogram to highlight all water pixels but no ideally no other features (i.e. land, clouds).
Example histogram, actual shape and values may be different.
You can zoom in on the histogram by holding down your middle mouse button to draw a box in the histogram the area that you want to zoom in on.
Click OK in the Choose Threshold Parameters dialog. This should have done a good job at selecting the water pixels. Your ROI should now include all of the water areas in the image. In the ROI Tool menus save the ROI (File →Save As) as "water-mask" in your Final folder. Close the ROI tool window.
We will now use the ROI to mask the image. In the Main toolbar, select File → Save As → Save As.. (ENVI). In the Data Selection Window select the "surface_reflectance.dat" as the Input File. Click the Mask button below. In the Mask Selection Window select the "Water" ROI and click OK. Click OK in the Data Selection window to save the file.
Keep the default settings (ENVI format and default data ignore value) and enter an output filename as water.dat and save in your Final folder. Click
OK to run the masking and saving operation. You should now see an image where only the water is visible, the colors of the water and algae may appear exaggerated. Uncheck or remove the ROI from the layer manager.
Visualizing the Algae Blooms with Color Tables and Raster Color Slices
Individual bands can be visualized in several different ways. The default is gray-scale, with low values appearing dark and high values light or white. This can be changed by selecting a different Color Table or Color Ramp for the layer. We will use these tools to highlight the areas of the Lake Erie with significant algae growth. Lake areas with significant algae growth will have higher reflectance in the green wavelengths, therefore we will open just the Green wavelength data to visualize the algae bloom.
Open Green Band as Grayscale & Change Color Table
Open the Data Manager and scroll down to find "Water.dat". You should see all of the bands listed. Click on the Green band and select "Load Grayscale". A grayscale or black and white display of the green reflectance will appear in the window.
Right click on the layer in the Layer Manager and select Change Color Table. You can select one the presets or click "More" for more options and the ability to customize the colors. This allows you to quickly visualize difference in the pixel values of a layer. Select a color table that you think best highlights the algae growth.
The Green band with a color table applied to visually show the algae concentrations in the water.
Raster Color Slice Another way to visualize single band raster data is to use the Raster Color Slice tool. Use the Raster Color Slices tool to select data ranges and colors to highlight areas of an image. You can save the color slices visualization to a classification or to a shapefile. This allows you to create a colors scheme that highlights specific data ranges. This is also useful for comparing multiple data sets.
In the Layer Manager, right-click the green bands of the water.dat and select New Raster Color Slice.
Select the input file and band in the File Selection dialog, then click OK. The Edit Raster Color Slices dialog appears. The following default settings are used for the histogram; you can change them as needed, Number of slices = 16 Color table = Rainbow Minimum and maximum data ranges, calculated from the input image.
To alter the default color slices, select New Default Color Slices in the tool window. Try changing to less classes (try 10 for example) or change the minimum/maximum values to change the values of each slices. Click OK to to see the changes. If you would like to save your raster color slices, Click the Export drop-down button in the Edit Raster Color Slices and select Export Classified Image and save as a .dat file.
Calibrate, Mask and Visualize Landsat Thermal Data
When you download Level-1 Landsat 8 data
it also includes the thermal data collected by the Thermal Infrared Sensor (TIRS) on Landsat 8. The thermal data for Landsat 8 can easily be calibrated using ENVI. The calibrated data will display the approximate surface temperature in Kelvin.
Now we will calibrate the thermal data so the pixel values represent temperature in Kelvin. From the Toolbox, select Radiometric Correction → Radiometric Calibration or type “radiometric” in the toolbox and the Radiometric Calibration tool will appear in the toolbox below.
In the Radiometric Calibration window we need to select the thermal data as the Input Raster. . In the Select Input File window, select the "MTL_LC08....._MTL_Thermal" file. Then click the Mask button, we will use the same ROI to mask the water areas. In the Mask Selection Window select the "Water" ROI and click OK.
In the next window select "Brightness Temperature" as the calibration type (leave the Scale Factor at 1). Name your output file file "Water_temperature.dat" and save it in your Lab 8 Final folder. When the process is complete the calibrated thermal image should automatically open. You should now see thermal data for the water. It will be displayed in grayscale by default.
Create a new view (Views→New View) and drag the "water_temperature.dat" file and "surface_reflectance.dat" into the new view, placing the thermal data (water_temperature.dat) on top of the true color Landsat image (surface_reflectance.dat). Remove the thermal data from the other viewer. Use the techniques above (step 37) to visualize the thermal data using different color tables. Select the color table that you think best displays the thermal data.
Contrast Stretch Thermal and Algae (Green) Layers
The last thing we will look at is the Contrast Stretch Tool, which is an image enhancement tool. ENVI automatically applies a contrast stretch to all images but you are free to change the contrast stretch at anytime. Learn More About the Stretch Types
Try applying different contrast stretches to the single band thermal data (water_temperature.dat) and the single band (green) data (water.dat). Notice how the ranges of colors change with the contrast stretches. Select a Contrast Stretch for each that you think best displays the data or choose a Raster Color Slice to display the data. Zoom in on Lake Erie and take a screenshot or use the Chip to View tool to save a jpeg of the (1) thermal image and the (2) green band image (algae), use the true color satellite image as the background for both of the images (surface_reflectance.dat).
Algae concentrations (green band) on the left and surface temperature (right). Note this imagery is from a September 2017 Landsat 8 image, your data and imagery will differ.
Make sure you all the images you need (see before closing ENVI. Back up your Lab 8 finals folder by zipping it and copying to a USB drive or Google Drive.
Lab Report (Upload to Canvas)
Prepare a lab report that includes a methods and results/discussion with each section separated with a heading.
Your report need to include the following information:
Title, Name and Date
Methods: Discuss the data and methods you employed in this Lab to process the data. This does not need to be a step-by-step explanation but should be sufficiently detailed that someone with applicable knowledge could replicate the analysis. When writing the methods section, assume that the reader is someone who is familiar with the basic practices of your field. Always include the specific data used( type, date acquired etc.), as well as the study location.
Results: Describe the results of the processing including:
How the different images looked in terms of contrast and appearance.
How the spectral profiles and pixel values (reflectance values) differed between the processed images.
Where (in terms of geographic area and land use type) the algae blooms appear to most concentrated
Note any relationship between the surface temperature of the water and algae concentration
Note where the algae blooms appear to be coming from or the areas with the densest concentrations.
Figures (4)
Spectral Profile Plot comparing the spectral reflectance data for the two processed images
True color Landsat Image with Contrast Stretch of your choice applied
Landsat Image focused on Lake Erie with Color Table showing the relative algae concentrations (green band of water.dat)
Landsat Image focused on Lake Erie with Color Table showing the surface temperature of the water (water_temp.dat)
Table (1)
Table showing the reflectance values for a selected water pixel in the two different processed images. Include appropriate labels and caption.
Contact Info
Humboldt State University
1 Harpst Street Arcata, CA 95521
skh28@humboldt.edu