A computer-implemented method for generating a reshaping function for reshaping an input image in a first codewords representation to a reshaped image in a second codewords representation, the method comprising: accessing a first set of pre-computed reshaping functions, wherein a pre-computed reshaping function of the first set maps pixel codewords from the first codeword representation to the second codeword representation and each reshaping function is identified by a value of a parameter, wherein the value of the parameter corresponds to a device setting of a device for capturing or displaying the input image or the reshaped image; receiving an input image in the first codeword representation and a parameter identifying the reshaping function to be generated, wherein the first set of pre-computed reshaping functions does not comprise the reshaping function to be generated; identifying within the first set of pre-computed reshaping functions a first pre-computed reshaping function identified by a first parameter having a first value lower than a value of said received parameter and a second pre-computed reshaping function identified by a second parameter having a second value higher than the value of said received parameter, the value of the received parameter being different from any values of the parameters identifying the pre-computed reshaping functions of the first set; generating the reshaping function by interpolating the first pre-computed reshaping function and the second pre-computed reshaping function based on an interpolation factor computed using the received parameter, the first parameter and the second parameter; applying the generated reshaping function to the input image to generate the reshaped image in the second codeword representation; and coding the reshaped image to generate a coded reshaped image. accessing a first set of pre-computed reshaping functions, wherein a pre-computed reshaping function of the first set maps pixel codewords from the first codeword representation to the second codeword representation and each reshaping function is identified by a value of a parameter, wherein the value of the parameter corresponds to a device setting of a device for capturing or displaying the input image or the reshaped image; receiving an input image in the first codeword representation and a parameter identifying the reshaping function to be generated, wherein the first set of pre-computed reshaping functions does not comprise the reshaping function to be generated; identifying within the first set of pre-computed reshaping functions a first pre-computed reshaping function identified by a first parameter having a first value lower than a value of said received parameter and a second pre-computed reshaping function identified by a second parameter having a second value higher than the value of said received parameter, the value of the received parameter being different from any values of the parameters identifying the pre-computed reshaping functions of the first set; generating the reshaping function by interpolating the first pre-computed reshaping function and the second pre-computed reshaping function based on an interpolation factor computed using the received parameter, the first parameter and the second parameter; applying the generated reshaping function to the input image to generate the reshaped image in the second codeword representation; and coding the reshaped image to generate a coded reshaped image. <EOS>