(im_ndwi, cloud_mask, im_ref_buffer)
return contours, t_otsu
Traditional method for shoreline detection using a global threshold.
    Finds the water line by thresholding the Normalized Difference Water Index 
    and applying the Marching Squares Algorithm to contour the iso-value 
    corresponding to the threshold.

    KV WRL 2018

    Arguments:
    -----------
    im_ndwi: np.ndarray
        Image (2D) with the NDWI (water index)
    cloud_mask: np.ndarray
        2D cloud mask with True where cloud pixels are
    im_ref_buffer: np.array
        Binary image containing a buffer around the reference shoreline

    Returns:    
    -----------
    contours: list of np.arrays
        contains the coordinates of the contour lines
    t_mwi: float
        Otsu threshold used to map the contours
Traditional method for shoreline detection using a global threshold.
    Finds the water line by thresholding the Normalized Difference Water Index 
    and applying the Marching Squares Algorithm to contour the iso-value 
    corresponding to the threshold.
Traditional method for shoreline detection using a global threshold . Finds the water line by thresholding the Normalized Difference Water Index and applying the Marching Squares Algorithm to contour the iso - value corresponding to the threshold .
def find_wl_contours1(im_ndwi, cloud_mask, im_ref_buffer):
    """
    Traditional method for shoreline detection using a global threshold.
    Finds the water line by thresholding the Normalized Difference Water Index 
    and applying the Marching Squares Algorithm to contour the iso-value 
    corresponding to the threshold.

    KV WRL 2018

    Arguments:
    -----------
    im_ndwi: np.ndarray
        Image (2D) with the NDWI (water index)
    cloud_mask: np.ndarray
        2D cloud mask with True where cloud pixels are
    im_ref_buffer: np.array
        Binary image containing a buffer around the reference shoreline

    Returns:    
    -----------
    contours: list of np.arrays
        contains the coordinates of the contour lines
    t_mwi: float
        Otsu threshold used to map the contours

    """

    # reshape image to vector
    vec_ndwi = im_ndwi.reshape(im_ndwi.shape[0] * im_ndwi.shape[1])
    vec_mask = cloud_mask.reshape(cloud_mask.shape[0] * cloud_mask.shape[1])
    vec = vec_ndwi[~vec_mask]
    # apply otsu's threshold
    vec = vec[~np.isnan(vec)]
    t_otsu = filters.threshold_otsu(vec)
    # use Marching Squares algorithm to detect contours on ndwi image
    im_ndwi_buffer = np.copy(im_ndwi)
    im_ndwi_buffer[~im_ref_buffer] = np.nan
    contours = measure.find_contours(im_ndwi_buffer, t_otsu)
    # remove contours that contain NaNs (due to cloud pixels in the contour)
    contours = process_contours(contours)

    return contours, t_otsu
def find_wl_contours1 ( im_ndwi , cloud_mask , im_ref_buffer ) : # reshape image to vector vec_ndwi = im_ndwi . reshape ( im_ndwi . shape [ 0 ] * im_ndwi . shape [ 1 ] ) vec_mask = cloud_mask . reshape ( cloud_mask . shape [ 0 ] * cloud_mask . shape [ 1 ] ) vec = vec_ndwi [ ~ vec_mask ] # apply otsu's threshold vec = vec [ ~ np . isnan ( vec ) ] t_otsu = filters . threshold_otsu ( vec ) # use Marching Squares algorithm to detect contours on ndwi image im_ndwi_buffer = np . copy ( im_ndwi ) im_ndwi_buffer [ ~ im_ref_buffer ] = np . nan contours = measure . find_contours ( im_ndwi_buffer , t_otsu ) # remove contours that contain NaNs (due to cloud pixels in the contour) contours = process_contours ( contours ) return contours , t_otsu