Optimizing hue calculation