generic non-linear filtering that support selem and boundary handling