shadowmask.py
Method
Marker pixels for cloud-shadows are identified through firstly projecting the cloud segments away from the sun and defining a search area, and secondly, selecting a threshold based on the difference of the histograms of pixels within and without the search area. Shadow segments are then grown from the markers using the watershed transform.
Modes
The program has four modes, which can be used in sequence.
- Use auto mode to generate a shadow mask, a shapefile of shadow marker points, and a blank polygon shapefile in case it is needed.
- Edit the point shapefile to reduce errors, and rerun the program in points mode.
- If any shadows are not masked, the polygon shapefile can be edited, and the program can be run in points_and_polys or polys mode.
- Review mode can be used to vectorise an existing mask image for editing.
Limitations
The program makes the following assumptions
- Output files are in Imagine (HFA) file format only.
- The cloud mask image has already been produced.
- The image metadata is either a dim file for SPOT-5 HRG imagery, or a meta file for USGS Landsat TM/ETM+ imagery.
- When processing USGS Landsat TM/ETM+ images the program will look for a water index image (where water is <= 68), which can reduce cloud shadow commission errors.
Examples
To run in auto mode on a SPOT-5 image called test.img:
shadowmask.py -i test.img -m auto --sensor SPOT
--cloudfile cloudmask.img --maskimage shadowmask.img \
--pointfile shadowpoints.shp --polyfile shadowpolys.shp \
--metafile test.dim --cloudheight low
If the qvf and history modules are installed (written by JRSRP-DERM) you can use standard names:
shadowmask.py -i s5hgre_49353489_20081109_bbfm5.img -m auto -s
Help
Usage: shadowmask.py [options]
Options:
-h, --help
Show this help message and exit
-i, --image <string>
REQUIRED. Cloudy image in any GDAL format, as either unsigned 8 or 16
bit integer.
-m, --mode <auto|points|polys|points_and_polys|review>
REQUIRED. The mode to operate in.
-s, --standard
Use standard JRSRP filenames.
--sensor <SPOT|TM>
Sensor used to acquire the image.
--cloudfile <string>
Binary cloud mask.
--maskimage <string>
Binary shadow mask image to be produced.
--pointfile <string>
Point shapefile marking shadows.
--polyfile <string>
Polygon shapefile outlining shadows.
--metafile <string>
Metadata file that contains the sun and sensor aquisition angles, meta
format for TM and dim format for SPOT.
--cloudheight <low|high|both>
Estimated cloud height, which is used to limit the shadow search area
(default=low).
--waterfile <string>
Water index image where water is <=68, for TM imagery only (standard
JRSRP product).
--buff <int>
The number of additional pixels used to buffer the cloud mask image.