1. A method for coding a sequence of input enhanced dynamic range (EDR) images comprising image blocks, the method comprising: receiving said sequence of input enhanced dynamic range (EDR) images; computing block-complexity metrics for one or more of the image blocks in at least one input image in the sequence of input EDR images, said block-complexity metrics being representative for a variation in pixel values; constructing a first set of the image blocks, the first set comprising image blocks for which their computed block-complexity metric satisfies a predetermined criterion; for each block in the first set of the image blocks determining an optimal slope (k(j,n)) according to a slope generation function for a linear quantization model, said optimal slope representing a minimal slope of the linear quantization model for said block; for each input code word (v c ) of the sequence of input EDR images: constructing a second set of image blocks, the second set comprising blocks that belong to the first set of the image blocks and wherein the input code word is within minimum and maximum pixel values of the image block; and generating an envelope slope (k(v c )) for the input code word, said envelope slope being computed using the maximum optimal slope among the optimal slopes of the blocks in the second set of image blocks; computing a sum (k) of all the envelope slopes for all code words; and for each input code word: generating a cumulative slope (K(v c )), the cumulative slope comprising a sum of the envelope slopes up to and including said input code word; and generating a mapping function between the input code word and an output code word, the mapping function computed from the cumulative slope of the code word and the sum of all the envelope slopes for all code words.