optimized local filtering