cloudmask.py
Method
Marker pixels for clouds are identified as all pixels above a histogram based threshold, using the green band. Cloud 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 cloud mask, a shapefile of cloud 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 thin cloud is 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 has some limitations which influence the way it should be implemented:
- Output files are in Imagine (HFA) file format only.
- The method of using marker points to identify clouds was designed to work with images contaminated by scattered cloud only, and is not effective on images with significant cloud cover. Images with substantial cloud cover should be masked with the polygon option.
- Multiple marker points may be required for single cloud objects, as internal variation in the cloud, or increasing distance from the marker, may stop the growth of the cloud mask before it reaches the true edge of the cloud.
- The accuracy of the final mask is often dependant on the time available for masking. Images with lots of thin discontinuous cloud will take the longest editing times, and the operator will have to decide when enough time has been spent, even if not all the cloud has been masked.
Examples
To run in auto mode on a Landsat TM image called test.img:
cloudmask.py -i test.img -m auto --sensor TM \
--maskimage cloudmask.img --pointfile cloudpoints.shp \
--polyfile cloudpolys.shp
If the qvf and history modules are installed (written by JRSRP-DERM) you can use standard names:
cloudmask.py -i l5tmre_p090r081_20110904_da1m6.img -m auto -s
Help
Usage: cloudmask.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.
--maskimage <string>
Binary cloud mask image to be produced.
--pointfile <string>
Point shapefile marking cloudy regions.
--polyfile <string>
Polygon shapefile outlining cloudy regions.
--buff <int>
The number of additional pixels used to buffer the cloud mask image.