Hi:Now It supports nd. but less of test. this image, skimage cost 20s, mine less than 1s.It is wrriten with numba in 90 lines. did not support compactness, but it's simple, and fast. YXDragon
Thanks for this. Simple functions are very good for one’s own images, as well as to understand an algorithm, but for a widely used library like scikit-image, flexibility and robustness are least as important as speed. In skimage, we aim to support floating point input images, for which your code won’t work. There is a lot of thought into edge cases going into the skimage implementation, which unfortunately could have an effect on performance. The question we need to solve isn’t “can we make a super-fast watershed implementation”, but, “can we make a flexible and robust implementation that is also fast?” Using Numba is certainly not off-limits, but any candidate implementation should at a minimum pass the skimage test suite.
I once tried a level-by-level implementation of watershed, by the way. It has a fatal flaw, which is that valleys with no markers will never get labeled. Here’s a test case that works with skimage but fails in your implementation. (Note also that your implementation overwrites the seeds image, which is pretty crazy. =)
In : import watershed In : from skimage import morphology In : import numpy as np In : image = np.array([1, 0, 1, 0, 1, 0, 1], dtype=np.uint8) In : seeds = np.array([0, 1, 0, 0, 0, 2, 0]) In : morphology.watershed(image, seeds) Out: array([1, 1, 1, 1, 2, 2, 2], dtype=int32) In : watershed.watershed(image, seeds) Out: array([0, 0, 0, 0, 0, 0, 0]) In : seeds Out: array([0, 0, 0, 0, 0, 0, 0])
On 12 Sep 2017, 6:34 AM +1000, firstname.lastname@example.org, wrote:
Hi: Now It supports nd. but less of test. this image, skimage cost 20s, mine less than 1s. It is wrriten with numba in 90 lines. did not support compactness, but it's simple, and fast.
YXDragon _______________________________________________ scikit-image mailing list email@example.com https://mail.python.org/mailman/listinfo/scikit-image