Reduce computation time for bilateral upsampling.

Compute the distance values (exponential functions) in advance to reduce computation time.