Computationally efficient, one-pass algorithm for morphological filters