Optimizations for Bilateral filter