From 5f30bb6bd40346a726e858b88f6c91bc1bf3a387 Mon Sep 17 00:00:00 2001 From: Sharon Fitzpatrick Date: Mon, 20 May 2024 17:51:18 -0700 Subject: [PATCH] update the cloud mask issue creation fromissue #407 from coastsat --- src/coastsat/SDS_preprocess.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/coastsat/SDS_preprocess.py b/src/coastsat/SDS_preprocess.py index e0ccd4b..f3251b2 100644 --- a/src/coastsat/SDS_preprocess.py +++ b/src/coastsat/SDS_preprocess.py @@ -905,15 +905,15 @@ def is_set(x, n): cloud_mask = morphology.remove_small_objects( cloud_mask, min_size=40, connectivity=1 ) - if cloud_mask_issue: - elem = morphology.square(6) # use a square of width 6 pixels - cloud_mask = morphology.binary_opening( - cloud_mask, elem - ) # perform image opening - # remove objects with less than min_size connected pixels - morphology.remove_small_objects( - cloud_mask, min_size=100, connectivity=1, out=cloud_mask - ) + # this is only for if the cloud mask was applied to the shoreline accidentally + if cloud_mask_issue: + cloud_mask = np.zeros_like(im_QA, dtype=bool) + for value in cloud_values: + cloud_mask_temp = np.isin(im_QA, value) + elem = morphology.square(6) # use a square of width 6 pixels + cloud_mask_temp = morphology.binary_opening(cloud_mask_temp, elem) # perform image opening + cloud_mask_temp = morphology.remove_small_objects(cloud_mask_temp, min_size=100, connectivity=1) + cloud_mask = np.logical_or(cloud_mask, cloud_mask_temp) return cloud_mask