SatelliteShorelines / CoastSeg

An interactive toolbox for downloading satellite imagery, applying image segmentation models, mapping shoreline positions and more. The mapping extension for CoastSat and Zoo.
https://satelliteshorelines.github.io/CoastSeg/
GNU General Public License v3.0
49 stars 10 forks source link

Bug: The reference shoreline buffer is not being applied correctly in zoo #221

Closed 2320sharon closed 9 months ago

2320sharon commented 10 months ago

In Zoo the reference shoreline buffer is not being applied correctly. Shorelines are being extracted even when they are outside the reference shoreline buffer as shown in the figure below. I have verified via the example below that the reference shoreline buffer is being plotted correctly, but it doesn't appear to be applied correctly.

What's weird though is that if I increase the size of the buffer more shorelines are being extracted as seen in the second figure.

1984-11-01-15-03-39_L5 1984-07-03-15-08-24_L5

2320sharon commented 9 months ago

I figured out the cause of this bug at last! When shorelines are extracted from the image the reference shoreline buffer is dilated by 5 pixels in both the coastsat_package workflow and the zoo workflow. The issue is the reference shoreline buffer shown in the plots was not dilated at all meaning that the reference shoreline buffer shown on the plots did not reflect the actual reference shoreline buffer used to extract the shoreline.

    # dilate the reference shoreline buffer by 5 pixels to mask out anything outside the reference shoreline buffer
    se = morphology.disk(5)
    im_ref_buffer_extra = morphology.binary_dilation(im_ref_buffer, se)

Without Dilating Shoreline Buffer on Plot

With Dilating Shoreline Buffer on Plot

Solution

Tasks

Update

The reference shoreline buffer plotted by the coastsat workflow is correct because it uses the dilated buffer to plot the shorelines unlike the zoo workflow.

2320sharon commented 9 months ago

So this issue was bit more complicated than I previously thought. Here is what actually ended up being the solution. I found out within coastsat_package find_wl_contours2 and find_wl_contours1 that both of these functions were dilating the reference shoreline buffer by 5 pixels and keeping only the data within that region. The same was happening in the zoo workflows simplified_find_contours function. This would normally be fine except the SDS_shoreline.create_shoreline_buffer had already dilated the shoreline reference buffer by 5 pixels meaning that the buffer was being dilated by a total of 10 pixels, but the plot only reflected the 5 pixel dilation. I modified coastsat_package and simplified_find_contours to no longer dilate the reference shoreline buffer after it was dilated.