refine the bgr to lab function