A method for content-adaptive forward reshaping of an input image in an input bit depth to a corresponding output image of a target bit depth, comprising: accessing the input image in the input bit depth, wherein the input image comprises luminance values quantized in the input bit depth within an allowed luminance range as defined by the format of the input image; dividing a set of codewords at the target bit depth into a plurality of subsets of codewords, wherein each codeword corresponds to a luminance value quantized in the target bit depth, wherein the set of codewords corresponds to an allowed luminance range as defined by the format of the output image, and wherein the target bit depth is less than or equal to the input bit depth; dividing the allowed luminance range as defined by the format of the input image into a plurality of luminance subranges; assigning each of the codeword subsets into a respective one of the luminance subranges; assigning an indication of visual importance to each of the luminance subranges, wherein the indication of visual importance is a predetermined value indicating a weighting of the content-adaptive reshaping according to the human visual system; assigning to each of the codeword subsets the indication of visual importance of the luminance subrange to which it is assigned; and allocating, to each codeword subset, a number of the codewords according to a codeword mapping function, wherein for a first codeword subset with an assigned indication of visual importance higher than the indication of visual importance assigned to a second codeword subset, the codeword mapping function allocates more codewords to the first codeword subset than to the second codeword subset; generating a forward reshaping function based on the codeword allocation in each codeword subset, the forward reshaping function being a function for mapping the luminance values of the input image to corresponding codewords of the output image; and applying the forward reshaping function to the luminance values of the input image to generate the corresponding codewords of the output image. accessing the input image in the input bit depth, wherein the input image comprises luminance values quantized in the input bit depth within an allowed luminance range as defined by the format of the input image; dividing a set of codewords at the target bit depth into a plurality of subsets of codewords, wherein each codeword corresponds to a luminance value quantized in the target bit depth, wherein the set of codewords corresponds to an allowed luminance range as defined by the format of the output image, and wherein the target bit depth is less than or equal to the input bit depth; dividing the allowed luminance range as defined by the format of the input image into a plurality of luminance subranges; assigning each of the codeword subsets into a respective one of the luminance subranges; assigning an indication of visual importance to each of the luminance subranges, wherein the indication of visual importance is a predetermined value indicating a weighting of the content-adaptive reshaping according to the human visual system; assigning to each of the codeword subsets the indication of visual importance of the luminance subrange to which it is assigned; and allocating, to each codeword subset, a number of the codewords according to a codeword mapping function, wherein for a first codeword subset with an assigned indication of visual importance higher than the indication of visual importance assigned to a second codeword subset, the codeword mapping function allocates more codewords to the first codeword subset than to the second codeword subset; generating a forward reshaping function based on the codeword allocation in each codeword subset, the forward reshaping function being a function for mapping the luminance values of the input image to corresponding codewords of the output image; and applying the forward reshaping function to the luminance values of the input image to generate the corresponding codewords of the output image.