Search code examples
imagematlabimage-processingcolorscolor-management

Matlab restoring an image to its original colors


I want to take a picture of something.

The colors in the picture are not the same as I see in my eyes.

So in order to fix this problem, I decided to place a red paper (with RGB: [255 0 0]) and then take a picture including this paper.

If I see that the RGB of the paper is changed (such as [243 15 7]), I will change all the RGB in the picture by the next way:

  • R (red), it will be added by value 12.
  • G (green), it will be subtracted by value 15.
  • B (blue), it will be subtracted by value 7.

By this way, my paper will be changed to his correct RGB [255 0 0] and then I can be sure that all the rest picture's RGB was changed to its original color.

What do you think about this way?


Solution

  • What you are trying to do is called Color Management/Color Correction.

    I have some remarks:

    • First, you must make sure that your monitor is calibrated. If it isn't calibrated, it makes no sense to do a visual check. If you have a standard consumer monitor, chances are that you cannot calibrate it at all.
    • Why do you assume that the RGB of the paper is [255,0,0]? It could be slightly greener or bluer. You should use a known target, like Macbeth ColorChecker
    • The offset transformation that you are using, will not work if amount of light is changed. Instead, it should be multiplicative to be invariant to illumination intensity. Check out the standard method of color correction, Color Correction Matrix.
    • You will need more than one known color. Three is the absolute minimum to calibrate the matrix.