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

"wrap" mode for label #189

Closed
rabernat opened this issue Feb 8, 2021 · 8 comments
Closed

"wrap" mode for label #189

rabernat opened this issue Feb 8, 2021 · 8 comments

Comments

@rabernat
Copy link

rabernat commented Feb 8, 2021

Over in scipy/scipy#8218 we are discussing how to implement "wrap" mode (i.e. periodic boundary conditions) for label and other morphological functions. (This issue is just about label.) We would like to be able to call label and have features that cross the array's periodic boundary (in our case, the date line), be counted as a single feature.

I'm opening this issue because

  1. If implemented, we would eventually want to propagate this feature downstream to dask-image
  2. It strikes me that you have essentially already implemented it! Dask-image is able to automatically unify labels across neighbor chunks. This code seems to live in https://github.com/dask/dask-image/blob/main/dask_image/ndmeasure/_utils/_label.py. For "wrap" mode, we could apply basically the same approach, but treating the array as its own neighbor chunk.

It sounds like the scipy-devs are open to accepting a PR to implement wrap-mode via a relabeling approach. So I am wondering if you folks here have any advice about how to best extract / adapt your relabeling method to live in scipy itself. Thanks in advance for any advice or hints you might be able to share.

And thanks for the amazing dask-image package! It is super helpful for all our work.

cc @hscannell

@jakirkham
Copy link
Member

cc @jni

@GenevieveBuckley
Copy link
Collaborator

@jni authored https://github.com/dask/dask-image/blob/main/dask_image/ndmeasure/_utils/_label.py so I'd say he's probably the best person to guide you.

@jakirkham
Copy link
Member

cc @grlee77 (also in case you have thoughts on how we might consolidate this upstream)

@jni
Copy link
Contributor

jni commented Feb 19, 2021

Hi everyone,

I'm sorry that I haven't had the bandwidth to respond here properly, much less consider the code carefully. I do love that code, which @jakirkham and I implemented over a feverish couple of days in 2019 here in Melbourne — remember in-person visits?

Anyway, I think your assessment is right @rabernat, the very same code can almost certainly be used to wrap the arrays, modulo some connectivity parameter. It'd be equally fun to implement, should someone have the bandwidth. I'd love to say I would do it but realistically I won't get the chance any time soon.

@Holmgren825
Copy link
Contributor

Hey,
This is a bit old now but came across it looking for a way to wrap features over the date line in gridded geodata (Similar use to @rabernat I believe). I've managed to hack together an initial solution which merges features across the boundaries of the array. Would be happy to discuss further and try to get it up to standards if there is still some interest in this.

@jakirkham
Copy link
Member

Thanks Erik! 🙏

Maybe it is worth opening a PR to discuss the changes?

@Holmgren825
Copy link
Contributor

Sounds good! See #344.

@m-albert
Copy link
Collaborator

Closed by #344.

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

No branches or pull requests

6 participants