# Photodetector Question: Does converting an RGB image to grayscale produce the same result as using a grayscale image detector?

FYI my application is not astronomy related, but I know astronomy folks have a lot of knowledge of photodetection and spectrometry instrumentation, so I am seeking this community's help.

I'm interested in doing both spectral and RGB imaging. I'm wondering if I can do both with just an RGB CMOS camera... The way I would approach the spectral imaging is to illuminate my sample with monochromatic light one wavelength at a time and then convert the images to grayscale. Each grayscale image would represent the intensity of light reflecting from my sample at a particular wavelength. I would love for this to work, but I am doubtful that the converted image will actually represent what a grayscale camera would record.

Bit of an odd scenario... Wasn't sure how to search the web for this. Any help is appreciated! Thanks!

• What kind of sample do you have? If it was just reflecting light, your approach might work. Yet, if your sample emits light (i.e. absorbs your monochromatic light and emits it at a different wavelength), potentially also in a different position, you would not see the true spectral image. – engineer Mar 29 '16 at 7:20
• You will have to correct for the spectral response of your tunable light source, and for the spectral response of your detector. In a sense you will want to look at the differential response of your system with and without the target, or rather between your target and a reference target. – Conrad Turner Mar 29 '16 at 7:33
• The usual conversion for RGB to greyscale follows a formula like: Y = 0.216R + 0.715G + 0.072B en.wikipedia.org/wiki/Grayscale Unless you're extremely lucky in filter choice, I doubt you'll get the same answer as from conversion of a single RGB camera image. – Wayfaring Stranger Mar 29 '16 at 13:10
• @engineer My samples are silicon wafers. They are only reflecting, not fluorescing. – Brian Gawlik Mar 29 '16 at 20:46
• @ConradTurner I will certainly be using a reference. Probably an aluminum mirror. This is standard practice in spectrophotometry; it will account for the spectral response of the tunable light source and the spectral response of grayscale detectors, although I'm not sure it will account for the RGB nature of the camera in this particular case... – Brian Gawlik Mar 29 '16 at 20:48

Really, all cameras/detectors are greyscale detectors. Every pixel in a CCD detector puts out a single number for the number of photons it detected. To create an RGB image you need three filters. If you have 3 detectors, you can put a different filter in front of each and get 3 numbers at once. If you have 1 detector, then you take 3 measurements with a different filter each time. To create the color image, one combines these values but you have freedom to weight them as you like. Typically, one tries to imitate the sensitivity of the eye, but that is a complicated issue since the sensitivity of the eye to different colors changes with total intensity and the filters can not exactly reproduce the eye's bandpasses. So, there is no right way to do this. Some people like red more than blue, so they weight the R-band more. Once, you get aR+bG+cB, you loose the information you need to derive R, G, and B separately.

So, to do your experiment properly, you need to first get the response function (response vs wavelength) of the filters + CCD of your camera at each wavelength that you are using. You do this by imaging without the sample. Then repeat with the sample and divide "with" by "without", where "with" is the output in the R, G, or B channel that has the most response in the "without" case.

• Is that only because I won't have the coefficients a, b, and c? What if I did? Or are you saying that I surely won't? – Brian Gawlik Mar 29 '16 at 20:53
• These coefficients are not to be found in the image files, but I suppose you could look them up if you know the camera used and light levels etc. However, in the image file there are the individual values of aR, bG, and cB, indeed, you already have 3 separate greyscale images of the scene. – eshaya Mar 31 '16 at 15:54

OP here. For those who care, I think I figured out a solution; for my particular situation at least.

I'm pretty sure that as long as I use reference images for each wavelength I will be able to measure the reflectivity of my samples using RGB images converted to grayscale. Much like in spectrophotometry, I will be calculating the following ratio:

sample(wav)/ref(wav) = reflect(wav)

Where...

sample(wav) is a grayscale pixel value as a function of wavelength for images of the sample.

ref(wav) is a grayscale pixel value as a function of wavelength for images of the reference.

reflect(wav) is the reflectivity of the sample as a function of wavelength for an arbitrary pixel.

FYI my samples are Silicon wafers and the reference I will be using will be an Aluminum mirror. Both are specularly reflective.

Now I will attempt to prove that this makes sense mathematically...

Let's say at a particular wavelength there is some intensity reflected from the sample, I_sample(wav), and some intensity reflected from the reference, I_ref(wav). We want to measure something proportional to each of these intensities at each wavelength. Let's see if the RGB camera is going to screw us over or not...

The red, green, and blue filters each have there own transmission as a function of wavelength. Let's call these R(wav), G(wav), and B(wav). Thus the R,G,B values (0-255) that get recorded for the sample are proportional to R(wav)*I_sample(wav), G(wav)*I_sample(wav), B(wav)*I_sample(wav). And similarly for the reference we have R(wav)*I_ref(wav), G(wav)*I_ref(wav), B(wav)*I_ref(wav).

Converting these images to grayscale involves weighting the R, G, B values in the following manner: gray = aR+bG+cB. Which will give us the following grayscale pixel values:

sample(wav): a x R(wav) x I_sample(wav) + b x G(wav) x I_sample(wav) + c x B(wav) x I_sample(wav)

ref(wav): a x R(wav) x I_ref(wav) + b x G(wav) x I_ref(wav) + c x B(wav) x I_ref(wav)

A factor of aR(wav) + bG(wav) + c*B(wav) can be pulled out of each, and then if the ratio of sample(wav)/ref(wav) is calculated the common terms cancel leaving I_sample(wav)/I_ref(wav). This is reflectivity! Voila!

Hope this is correct... I have to go, but will continue to think about this, and will edit if I realize anything is wrong.

• I know I'm a little late to the party, but I found this question interesting. You are shooting the images in an otherwise light-free room? Meaning, there are no other light sources which could contaminate your spectral samples? – EastOfJupiter May 5 '16 at 13:48
• Yes, of course. – Brian Gawlik May 7 '16 at 1:31