1. A method for encoding image data, said method comprising: a) receiving a prediction base image based on a low dynamic range (LDR) image; b) receiving a high dynamic range (HDR) image corresponding to said LDR image; c) determining a difference image in the spatial domain, wherein said difference image represents the difference between said prediction base image and said HDR image; d) quantizing values of said difference image; e) sorting said quantized values of said difference image into an order, wherein said order is based on the values of corresponding pixels in said LDR image.