-
Notifications
You must be signed in to change notification settings - Fork 5
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
Exploring ideas for new shoreline extraction routines for application on label outputs of 4-class segmentation models #168
Comments
Upon reflection, I guess it's just one method really, with "method 2" being just an additional logic-based filter, and "method 3" being a way to use those found shorelines to trace a "shoreline path" through the entire image |
I tidied up my script, and added two more examples. It's simple and fast and seems quite robust. I'm quite pleased with it. all code and data here: |
I think the advantages are:
|
This is seriously cool and this should make extracting shorelines much faster. Would we still want to offer the same settings as coastsat for extracting shorelines with our model or do you think we may have to adapt them a bit? I believe we should adapt the settings to meet our needs when extracting shorelines instead of adhering to what coastsat has already built. |
I tested a few more images, this time a few more tricky examples and the results were interesting These ones worked great. The common theme is coastlines oriented from top to bottom ... However, at this site, the dynamic boundary tracing caused a problem, extrapolating the shoreline in an impossible area I think I know the solution to this problem and will work on it and update here later. Finally, the dynamic boundary tracing creates issues for non-straight shorelines, as we predicted: It feels so good to get to work on an image processing task! |
In the last two examples, it failed because the dynamic boundary tracing (DBT) is supposed to only work on straight(ish) interfaces, so I will try to think of a switch I can program in that determines when the DBT is/is not appropriate to apply ... |
If I implement all of the above ideas, here are the new outputs for all 9 images. Not bad! My files: |
Thanks for explaining your though process here. I gotta say you got some massive improvements with those techinques. Do you recommend any books, websites, or courses for learning more about image processing? I find it quite interesting and knowing more about it seems to be the key to solving these kinds of problems |
These routines should only be implemented for the 'zoo method'. i.e. using the segformer models. One nice thing about the approach is that it filters imagery based on label outputs, not image inputs. My logic is that it is probably a lot easier to identify bad images from model outputs (which are low-dimensional) than bad inputs (which are high dimensional). I'm making the case that it is harder to identify a bad image than a bad model output. The only real downside is the computational expense of pointing the model at each image, rather than only the 'good' ones. However, I feel like the ideal approach is a two-pronged approach:
|
I wanted to see if I could come up with a solution for shoreline extraction that starts with the 4-class label output as the basis. I put together a script to test this workflow, using an RGB image, the segformer RGB model, and cloud reference shorelines that I just made using GIMP for simplicity. These files are here
inputs_for_shoreline_extarction.zip
This is what they look like
First, I propose we filter the label image with the reference shoreline mask and the cloud mask. If our 4-class greyscale label is the variable
grey
, the binary cloud mask is calledcloud_mask
, and the binary shoreline buffer mask is calledref_shoreline_mask
From here, I have devised 3 new methods for shoreline extraction, each of which builds more complexity on top of the last
method 1: grab the land/water contour directly from this masked greyscale image
this is what we get:
method 2: same as method 1, but filter found shorelines that are very close to the boundary of the shoreline mask
We could achieve this using a distance function
now we have the distance matrix, we can further filter the label image based on a threshold distance in pixels. This is a matrix of pixel values that encode the distance to the boundary of the reference shoreline mask
Nice:
method 3: same as method 1 or 2, but use dynamic boundary tracing rather than contouring
It is a way to find the 'least-cost' path through an image, so is good for finding interfaces
Here are the new libraries and functions we need
Now we make a binary image where shoreline points are -1, everything else zero, and call the
dpboundary
function to thisThis one extrapolates to the edge of the image ... Nice!
We can discuss all this tomorrow @2320sharon . We need to test on some more images ...
code here: shoreline_detect.zip
The text was updated successfully, but these errors were encountered: