Support functions for watershed segmentation