deltametrics.plan.shaw_opening_angle_method¶
- deltametrics.plan.shaw_opening_angle_method(below_mask, query_set='sea', test_set='lwi+border', numviews=1, preprocess=True, parallel=0)¶
Extract the opening angle map from an image.
Applies the opening angle method [1] to compute the shoreline mask. Adapted from the Matlab implementation in [2].
This function takes an image and extracts its opening angle map.
- Parameters:
below_mask (ndarray) – Binary image that has been thresholded to split water/land. At minimum, this should be a thresholded elevation matrix, or some classification of land/water based on pixel color or reflectance intensity. This is the starting point for the opening angle method.
query_set (str, optional) – Where to compute the opening angle. Default is “sea”, consistent with the original paper. Also implemented is “lwi”, which approximates the view of open water from every point along the coast.
test_set (str, optional) – Which pixels to use as bounding in the opening angle calculation. Default (“lwi+border”)is to use land-water interface and the border of land pixels In some applications, a computational gain can be had by using “lwi”. These options differ from the description in [1] that describes the test set as comprising all land pixels; this behavior is accomplished by option “land”, but comes at considerable computational cost. Note that none of these options will avoid the issue (described in [1] where a barrier island 1 pixel wide may not properly block a view.
numviews (int, optional) – Defines the number of largest angles to consider for the opening angle map for each pixel. Default is 1, based on parameter $p$ in [1]. Note, this parameter is not an iteration count, but values >1 incur an additional sort operation, which can drastically increase computation time. Value in original paper [1] is numviews=3.
preprocess (bool or int, optional) – Whether to preprocess the input binary mask before applying the opening angle method. Preprocessing fills lakes that are entirely disconnected from the open water in the landmask. This is a helpful operation for reducing computational load and ensuring the “correct” shoreline is ultimately identified. Preprocessing is implemented in a manner consistent with [1].
parallel (int, optional) – Whether to use parallelization in the opening angle calculation. If sufficient processors are available, we recommend using two to four cores per mask being calculated. A value of 0 uses no parallelization, and other positive integers specify the number of threads to use (i.e., 1 also uses no parallelization).
- Returns:
opening_angles – The opening angle detected for each location in the input below_mask, with values determined according to the query_set.
- Return type:
ndarray
Examples
(
Source code
,png
,hires.png
)