Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Toggle for Cloud Masking #188

Closed
2320sharon opened this issue Aug 25, 2023 · 3 comments
Closed

Feature Request: Toggle for Cloud Masking #188

2320sharon opened this issue Aug 25, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request V1 Version 1 of Coastseg

Comments

@2320sharon
Copy link
Collaborator

Feature Request: Toggle for Cloud Masking

Description:
Introduce a toggle switch to enable or disable cloud masking. By default, this toggle would be set to "off". If users find that the Landsat's cloud masking algorithm erroneously labels beach pixels as cloud pixels, they can activate this switch to disable all cloud masking.

Proposed Solution:

  1. Add a toggle switch/button in the user interface, preferably in the settings or preferences section.
  2. Link the toggle's state (on/off) to the cloud masking function.
  3. When the toggle is "off", the cloud masking algorithm should be bypassed during image processing.

Benefits:

  • Provides flexibility to users in handling cloud masking based on their specific site conditions.
  • Increases the number of sites where shorelines can be effectively visualized by avoiding false cloud detections.

Drawbacks:

  1. Turning off cloud masking might expose actual cloud-covered areas, potentially affecting the accuracy of shoreline extraction in those regions.

Additional Context:

  • It would be beneficial to provide a tooltip or help section explaining the purpose and implications of the toggle to guide users in making informed decisions.
@2320sharon 2320sharon added enhancement New feature or request V1 Version 1 of Coastseg labels Aug 25, 2023
@2320sharon 2320sharon self-assigned this Aug 25, 2023
@2320sharon
Copy link
Collaborator Author

2320sharon commented Sep 1, 2023

I've been researching how cloud masks are created and how they applied within coastsat_package.

What is the cloud mask?

The cloud mask is a binary mask that indicates where cloud pixels have been identified. The version of the cloud mask returned by preprocess_single is the cloud mask merged via a logical OR operation
with the no_data mask.

Where is the cloud mask generated?

It is generated by the generate_cloud_mask function within preprocess_single.

Where is the cloud mask applied?

  1. rescale_image_intensity used by save_single_jpg
  2. create_shoreline_buffer
  3. classify_image_NN
  4. adjust_detection (we don't care becasue we set this to false)
  5. find_wl_contours1
  6. find_wl_contours2
  7. process_shoreline : uses only the cloud mask. Not the cloud mask with the no-data pixels in it
  8. show_detection

@2320sharon
Copy link
Collaborator Author

We found a way to save jpgs without the cloud mask thanks to @dbuscombe-usgs
here is the basic concept that need to be applied to preprocess_single

do_cloud_mask = False 
cloud_mask = create_cloud_mask(im_QA, satname, cloud_mask_issue, collection)

if not do_cloud_mask:
    cloud_mask[:]=False
    cloud_mask = get_nodata_mask(im_ms, cloud_mask.shape)
    # add pixels with -inf or nan values on any band to the nodata mask
    im_nodata = get_nodata_mask(im_ms, cloud_mask.shape)
    # check if there are pixels with 0 intensity in the Green, NIR and SWIR bands and add those
    # to the cloud mask as otherwise they will cause errors when calculating the NDWI and MNDWI
    im_zeros = get_zero_pixels(im_ms, cloud_mask.shape)
    # add zeros to im nodata
    im_nodata = np.logical_or(im_zeros, im_nodata)
else:
    cloud_mask = get_nodata_mask(im_ms, cloud_mask.shape)
    # add pixels with -inf or nan values on any band to the nodata mask
    im_nodata = get_nodata_mask(im_ms, cloud_mask.shape)
    # check if there are pixels with 0 intensity in the Green, NIR and SWIR bands and add those
    # to the cloud mask as otherwise they will cause errors when calculating the NDWI and MNDWI
    im_zeros = get_zero_pixels(im_ms, cloud_mask.shape)
    # add zeros to im nodata
    im_nodata = np.logical_or(im_zeros, im_nodata)

    # update cloud mask with all the nodata pixels
    cloud_mask = np.logical_or(cloud_mask, im_nodata)

@2320sharon
Copy link
Collaborator Author

This feature has been added in coastsat-package 0.1.16. There is a toggle in the basic settings that can be set to False to turn off cloud masking. This works for both downloading imagery and for extracting shorelines
pip install coastseg==0.0.75dev8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request V1 Version 1 of Coastseg
Projects
None yet
Development

No branches or pull requests

1 participant