Rewrote watershed to operate on sets of indices instead of logical array.