Debugged set-operation watershed algorithm (alternative to logical-indexing watershed algorithm)