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

Speed-up watershed segmentation using information from a binary image #34

Closed
VPetukhov opened this issue Jul 29, 2019 · 2 comments · Fixed by #33
Closed

Speed-up watershed segmentation using information from a binary image #34

VPetukhov opened this issue Jul 29, 2019 · 2 comments · Fixed by #33

Comments

@VPetukhov
Copy link

Following the example from the documentation, currently segmentation is performed on the whole image, and later it's filtered with the binary mask. Though, using mask during the segmentation would allow to significantly reduce computation time, avoiding computation for background pixels.

How about adding new optional parameter img_bin::Union{Array{Bool,2}, BitArray{2}, Nothing}=nothing to the function? So the interface will be changed from

watershed(img::AbstractArray{T, N}, markers::AbstractArray{S,N})

to

watershed(img::AbstractArray{T, N}, markers::AbstractArray{S,N}, img_bin::Union{AbstractArray{Bool,2}, BitArray{2}, Nothing}=nothing)

On my example, new function works 3.5 times faster. If you think it's fine, I will create a pull request.

@timholy
Copy link
Member

timholy commented Nov 23, 2019

This sounds reasonable to me! But perhaps it would be better to make it a keyword argument? Perhaps called mask or something?

@VPetukhov
Copy link
Author

But perhaps it would be better to make it a keyword argument? Perhaps called mask or something?

Yep, perhaps it would be better. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants