Algorithms for compression of high dynamic range images and video