Open kai-luca opened 1 year ago
Just chiming in that this would also be useful for one of the problems I'm working on.
I tested the suggested approach (remove the padding), and it nicely wraps around the array.
See test code: https://gist.github.com/stefsmeets/c7bf4f5c2fcee9ec9d7ae688e782ce9f
Edit: After testing the linked code for a while, it seems a bit unstable. It crashed from time to time (no bounds checking). It's also not correct, and only works in the horizontal direction, but not the vertical direction.
Hello scikit-image core devs! There hasn't been any activity on this issue for more than 180 days. I have marked it as "dormant" to make it easy to find. To our contributors, thank you for your contribution and apologies if this issue fell through the cracks! Hopefully this ping will help bring some fresh attention to the issue. If you need help, you can always reach out on our forum If you think that this issue is no longer relevant, you may close it, or we may do it at some point (either way, it will be done manually).
Hey, sorry for the slow response on our part and thanks for reaching out! Just to make sure I understand this feature request correctly: you want the algorithm to wrap around image borders when it fills the watershed?
I'm not opposed to this functionality, but because we operate on raveled images it may not be that trivial as the gist suggests. What might work is to keep wrapping with a boundary. And then if this boundary pixel is encountered figure out what the wrap-around neighbor is for this pixel.
This is also relevant for local_maxima
/ local_minima
.
No worries. In my view, this would be useful for a host of image analysis problems in the material sciences. For example when working with volumes/densities from simulations with periodic boundary conditions.
Yeah, indeed the wrap-around without the padding is not the wrap-around you want for periodic boundary conditions. For example, if you have an array of shape (10, 10) and you are at position (5, 0), your linearised neighbours are (4, 0), (6, 0), (5, 1) (as expected) and (4, 9) — here the 4 is unexpected. So you still need to do some arithmetic to do the wrapping correctly. However, I would definitely support a PR to add this feature, I think it's an excellent idea.
Description:
Adding periodic boundary conditions for the watershed transform would be an easy, yet practicable thing to do. It would make this library more usable for people using it to sort their simulation data(with periodic boundary conditions) into clusters. It also would be easy to implement since at the moment the picture is explicitly padded to remove periodic boundary conditions. Just make this padding the default but removable via function parameter.