Oft-stack mask2images.bash

From Open Foris Wiki

Jump to: navigation, search

This script uses two LEDAPS processed inputs to create a 14-band stack AND a mask for the oft-gapfill.

Usage: oft-stack_mask2images.bash <input1> <input2> [-notrim]


The inputs are given as directory names, containing the HDF files. The 14-band stack is named stack_input1_input2.img and the mask mask_input1_input2.img.


The default version of the script also trims the mask so that the image margins (= no image values) are excluded. If you want to leave them as they are, use the -notrim option.

The output mask values are:

  • 1 = fill these pixels (unusable data in anchor, good data in filler)
  • 2 = collect training data for regression model (good data in both images)
  • 3 = do nothing, i.e., use the original values (2 cases: good in anchor, bad in filler OR non-good in both images)
  • 0 = do nothing (image margins)

Example: oft-stack_mask2images.bash LE71660632009094ASN00 LE71660632006054ASN00 or oft-stack_mask2images.bash LE71660632009094ASN00 LE71660632006054ASN00 -notrim

Description:

  • The scrips utilizes the following programs: oft-calc, oft-trim, oft-shrink
  • Band4 of the LEDAPS corrected images ís used in the trimming phase and the QA_layer (band 8) for extracting the cloud, shadow and gap info. Furthermore, from version released on June 4 2012 on, only the "land" pixels as indicated by the QA layer are accepted.
  • The trimming is implemented as follows:
1. Resample the image to a coarser resolution in order to improve the recognition of gaps:
gdal_translate -outsize 10% 10% input.tif output.tif
2. Trim the margins and create an area for the actual mask (check in a 3 x 3 window if there are only values less or equal to zero. If so, output = 0, else output = 1:
oft-trim -ot Byte -ws 3 output.tif mask.tif
3. Repeat for the output file from step 2:
oft-trim -ot Byte -ws 3 mask.tif mask2.tif
4. Shrink:
oft-shrink -ws 11 mask2.tif mask.tif
5. Resample back to original resolution
  • The non-good image data are extracted from the bit-packed Ledaps QA band using the bit-level analysis property of oft-calc.

Exercise:

  • Get Example data set
  • For this exercise following tools are used: oft-stack_mask2images.bash

Back to Open Foris Toolkit Main Page

Back to Tools & Exercises



Personal tools