Matlab restoring an image to its original colors

2.3k views Asked by At

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?

3

There are 3 answers

3
Andrey Rubshtein On BEST ANSWER

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.
2
Botond On

i read about an iterative process of colour correction that could perhaps be applied in your case:

Correction with Photoshop in 7 Easy Steps by Helen Bradley,

nevertheless, confirm that it works as expected

good luck

3
fdermishin On

You can try to use white paper instead of red. By doing this, you will have information about three colors, not only red. In the perfect case, RGB values for white paper will be equal, for example, you get (197,197,197). But if they are not equal, for example (190, 204, 203), you can change them for each pixel by multiplying on some number:

mean = (190 + 204 + 203) / 3
red_new = red * mean / 190
green_new = green * mean / 204
blue_new = blue * mean / 203