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

Automatic island filtering by island vs channel size. #12

Open
Lvulis opened this issue Apr 14, 2020 · 8 comments
Open

Automatic island filtering by island vs channel size. #12

Lvulis opened this issue Apr 14, 2020 · 8 comments
Labels
documentation documentation to-do enhancement New feature or request good first issue Good for newcomers

Comments

@Lvulis
Copy link
Collaborator

Lvulis commented Apr 14, 2020

It would be very useful to have channels which are not really "channels" removed from the channel mask for a more accurate DCN to be extracted. We want narrow islands to be removed but only channels who are too narrow for the channel they are in. This is because we want bifurcations, not flow around some sandbars that are large enough.

One way to do this could be removing any island whose length is less than the width of the channel it is. Could do this simply thru hole filling below a certain threshold. However we need to KNOW how wide the channel to do this.

My initial idea/way to tackle it.
Run thru channel extraction and get channel widths. Then compute the size of islands in every channel. Apply a threshold (L_I > L_C), for any island objects that don't meet this criteria remove them by filling in the holes in the channel mask. L_I could be max radius or could be sqrt(Area). Then have to basically use the cleaned up channel mask and start back from beginning?!?!

Jon you suggested something of working in raster space - maybe a trick using the distance transform to estimate island width and channel width, and then blanking out islands whose max dist is lower than than channel width up or downstream.

@jonschwenk
Copy link
Collaborator

My inclincation here is to leave this up to the user when pre-processing masks. RivGraph has some tools that would help, and we could think about offering this as a mask pre-processing tool. @Lvulis suggests an iterative approach that RivGraphs the original mask, then fills it in based on the channel widths. This would probably work. Another approach would be to do all preprocessing raster space, using the distance transform on the mask to get channel widths, and the inverted mask to get island widths. Or can use RivGraph's regionprops utility to actually identify and measure all the islands. I would first attempt to leave everything in raster space as it's faster, simpler, and cleaner, but the tricky part is mapping a river width to each island, as there are no "groupings" that delineate which pixels should belong to the link. Perhaps an initial RG'ing of the mask would really simplify things, as it would be easy to identify islands encompassed by channels and compare their widths/sizes.

@jonschwenk jonschwenk added enhancement New feature or request good first issue Good for newcomers labels Jun 3, 2020
@jonschwenk
Copy link
Collaborator

I built some tools for this, see the new mask_utils.py script. I ended up going the iterative approach route so you can get the links surrounding the island in order to do the thresholding. I will make an example of island thresholding when I get a chance.

@Lvulis
Copy link
Collaborator Author

Lvulis commented Sep 3, 2020

Is this inside of RG 0.3 as of now? Will be great to have :)

@jonschwenk
Copy link
Collaborator

No, but if you just plop the mask_utils.py script in your Rivgraph folder (e.g. Anaconda3/envs/rivgraph/Lib/site-packages/rivgraph) you can import it and use it. I'm attaching a py script that I use for these functions; there are two major things to note: 1) there is a thresholding function that I designed for my use case; you'll probably want to customize it for yours. 2) It's best to put the island filling in a while loop as I've done, because as you fill in some islands, channel widths will change and might make islands that were once non-fillable, fillable.

Can't attach a py script so I'll email it.

@Lvulis
Copy link
Collaborator Author

Lvulis commented Dec 27, 2020

Jon was this ever developed further?

@jonschwenk
Copy link
Collaborator

Were you able to get the functions in mask_utils running? If so, do you have requests for further development? I used them to filter islands from a dozen deltas successfully.

@Lvulis
Copy link
Collaborator Author

Lvulis commented Dec 27, 2020

Sorry lost that script you had sent me and found out again. Yes I got it working, would be good to put it in the examples or somewhere.

@jonschwenk jonschwenk added the documentation documentation to-do label Dec 28, 2020
@jonschwenk
Copy link
Collaborator

Added a documentation tag and will close this if/when an example is made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation documentation to-do enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants