Stack filters: design algorithms and applications