1
votes

Consider I converted an image to RGB using

imrgb=cat(3,image1,image2,image3)

By default I am getting complete green image. However if I multiply image1 by 2 then color is changed to red and I can do this for other channels as well. Now my question is there any algorithm that find these numbers that should be multiplied by red,green and blue channels to get my desired image and assume I know my desired image.

1
Please include a minimal example containing code that will reproduce your problem. When I run the code above I get exactly what I would expect.beaker
I exactly type the above command but I should mention that I am working with uint16 images. I saw algorithm to convert RGB t grayscale.Is there an algorithm that can do reverse? is there algorithm that tell me if I want to get a given image I should multiply image1,image2 and image3 by different constants.stack
The problem is that we have no idea what image1, image2 and image3 you're using look like, so we're free to define them as we wish. How did you obtain these images? Are they all identical? And no, there is not, in general, a way to recover color information from a grayscale image.beaker
Please provide us with what image1, image2, and image3 are. It is impossible to reconstruct your problem and diagnose on how to solve it when you have provided little to no information other than the fact that you have those three images defined. Also, going from grayscale to the original colour image is impossible. You are going from a 1 dimensional problem to a 3 dimensional problem, which is completely unconstrained. There are many colours that satisfy one grayscale intensity, as going from colour to grayscale is a weighted sum of three components.rayryeng
Are image1, image2, and image3 grayscale images taken through known R,G,B color filters? That's the only way the question potentially makes sense.paisanco

1 Answers

0
votes

Probably your problem is that each channel is not normalized (has a different dynamic range).

Regarding your question: Yes. If you know your desired image than all you need to find is 3 constants for multiplications (one for each channel). If your image is of size 100x100 than you have 10,000 linear mathematical equations with 3 unknowns. This is easily solvable. In fact you only need 3 pixels to generate 3 equations, solve them an retrieve your constants. The standard solution is min square error achieved by SVD (singular value decomposition).

If you don't know your desired image than a quick and dirty way would be just re-normalize each of the 3 channels before you concatenate them to RGB. For example: img1. Find the minimal and maximal values (denoted by min,max) and change every value of the pixel to (v-min)/(max-min)*255. Do that for each of the 3 channels and than concatenate. This will solve the problem that you are experiencing where the dynamic range of each channel is different. However this is not the perfect solution. It works OK for natural images but may produce wrong results when the white balance in the image is offset (images of sun-set, sun-rise, swimming pools, vegetation, etc).