Alon Shmiel
Alon Shmiel

Reputation: 7121

Matlab restoring the image to its original colors

I asked it in the past, someone suggested me to use MACBETH but I don't have enough money for having it :/

enter image description here

So before I photographed, I've added 3 circles to the image to be places in the image: the first circle is red with RGB of [255 0 0], the second is green circle with RGB of [0 255 0] and the third is blue [0 0 255]. Thus I can see the change about the pixels average of each of them and fix the whole image by this change.

I have all the pixels of each circle. I made average of the pixels and I got the next thing:

The red circle's average RGB of its all contained pixels is [243 15 26].

the green circle's average RGB of its all contained pixels is [29 235 56].

and about the blue circle it is [14 33 250].

how can I fix the colors of each pixel in the image by the result of the new red\green\blue circles' RGB?

Upvotes: 2

Views: 779

Answers (1)

ypnos
ypnos

Reputation: 52367

If you assume a linear color mapping, you can construct a linear system that describes the change from original colors, e.g. (0, 0, 255) to observed colors, eg. (14, 33, 250).

Basically, y = A*x, where x is the original colors, y is the observed colors, A is the transformation matrix.

Once you calculated A, you can invert it to obtain the transform needed to go from y to x. You can then apply A^(-1) on all pixels for linear color correction.

Upvotes: 1

Related Questions