A method for processing image data, the method comprising the following steps: storing image data I WEB representative of an image in a memory, wherein said image data I WEB is in RGB format; receiving said image data I WEB in an image signal processor; transforming said image data I WEB into linear RGB format by applying inverse gamma correction to the image data Iwεs; applying an observer color-mapping function to said image data I WEB, comprising converting chromacity coordinates c S of said image data I WEB from a source tristimulus color space into chromacity coordinates c t in a target tristimulus color space, wherein said conversion is done using at least one of a conversion matrix M, wherein the size of said conversion matrix M is at least 3x3, wherein the conversion of said chromacity coordinates is done using a conversion matrix M according to the formula: c t = Mc s and wherein the method further comprises optimizing said conversion matrix M using a gradient descent algorithm in an iteration loop according to the formula: argmin M ∑ i ‖ c CIE − Mc sRGB ‖ where i refers to the number of colors used for said color-mapping function, c CIE represents the target chromacity coordinates in a standard color space, and c sRGB represents the source chromacity coordinates in the RGB color space; wherein each non-diagonal coefficient is optimized one by one, diagonal values are calculated right after each non-diagonal coefficient change to keep the sum of each row at 1, and after calculating all the coefficients, the optimization step is applied again until no improvement can be noticed; transforming said image data I WEB into a spectral matching color space where luminance components L and chrominance components care separated; providing values of a natural spectrum λ, covering the color gamut of a natural scene, in the same spectral matching color space as the image data is transformed into, from a database of natural spectra of natural scenes under typical illuminations; applying spectral matching to said image data I WEB in said spectral matching color space, wherein said luminance components L are omitted and color differences between said image and said natural spectrum λ are measured as the Euclidean distances between their pairs of chrominance components c; improving said spectral matching by modifying said natural spectrum λ into a corresponding modified natural spectrum λ in a sequence of iterative steps (1091, 1092) in which said Euclidean distances are minimized; and converting said image data I WEB to spectral image data I SPEC of a spectral image using said corresponding modified natural spectrum λ. storing image data I WEB representative of an image in a memory, wherein said image data I WEB is in RGB format; receiving said image data I WEB in an image signal processor; transforming said image data I WEB into linear RGB format by applying inverse gamma correction to the image data Iwεs; applying an observer color-mapping function to said image data I WEB, comprising converting chromacity coordinates c S of said image data I WEB from a source tristimulus color space into chromacity coordinates c t in a target tristimulus color space, wherein said conversion is done using at least one of a conversion matrix M, wherein the size of said conversion matrix M is at least 3x3, wherein the conversion of said chromacity coordinates is done using a conversion matrix M according to the formula: c t = Mc s and wherein the method further comprises optimizing said conversion matrix M using a gradient descent algorithm in an iteration loop according to the formula: argmin M ∑ i ‖ c CIE − Mc sRGB ‖ where i refers to the number of colors used for said color-mapping function, c CIE represents the target chromacity coordinates in a standard color space, and c sRGB represents the source chromacity coordinates in the RGB color space; wherein each non-diagonal coefficient is optimized one by one, diagonal values are calculated right after each non-diagonal coefficient change to keep the sum of each row at 1, and after calculating all the coefficients, the optimization step is applied again until no improvement can be noticed; transforming said image data I WEB into a spectral matching color space where luminance components L and chrominance components care separated; providing values of a natural spectrum λ, covering the color gamut of a natural scene, in the same spectral matching color space as the image data is transformed into, from a database of natural spectra of natural scenes under typical illuminations; applying spectral matching to said image data I WEB in said spectral matching color space, wherein said luminance components L are omitted and color differences between said image and said natural spectrum λ are measured as the Euclidean distances between their pairs of chrominance components c; improving said spectral matching by modifying said natural spectrum λ into a corresponding modified natural spectrum λ in a sequence of iterative steps (1091, 1092) in which said Euclidean distances are minimized; and converting said image data I WEB to spectral image data I SPEC of a spectral image using said corresponding modified natural spectrum λ.