0
$\begingroup$

Would it be possible to use a conventional Canon DSLR camera to do some kind of vaguely meaningful spectrum analysis with GNU Octave?

My niece needs to do a biology science project for school so I was thinking we could use her digital camera to periodically take images of a sample like a test tube of broth+yeast or proteins+enyzme or similar and then do some kind of image processing using Octave to do some kind of crude spectroscopy.

We have the computer doing tethered image capture no problem and I have octave processing the images and doing basic fft type stuff. But I'm not terribly familiar with signal processing and definitely not image processing so what would you recommend given the problem?

I am thinking the image should be processing in a homogeneous way. Meaning no one area of the image is more important than another. So some kind of averaging might be done first? Then an FFT?

How can I create an actual visible light spectrum?

For example, let's say we use a phenolphthalein type of reagent such that, as the pH of a sample changes, the absorbance of particular colors changes accordingly and so the camera and image processing ultimately yields some values that can be calibrated to different pH values.

$\endgroup$
0
$\begingroup$

Would it be possible to use a conventional Canon DSLR camera to do some kind of vaguely meaningful spectrum analysis with GNU Octave?

Yes. In fact, you don't need it to be a Canon DSLR, you can even do this with a web cam. The main idea is close to the real thing, you use a diffraction grating to separate the light components and a sensing element (e.g. a web cam) to "read" the colours. Spatial displacement corresponds to wavelength and there is also the dimension of the "strength" of a spectral line. In this way, you do away with the transformation between recorded colour and actual wavelength (more on this later).

For more information, please see this link and this link. If you want really fine control over your diffraction grating, you can use something like lightscribe to create a diffraction grating pattern at your exact specifications. There used to be some alternatives out there to create simple CD ISOs that when burned on a CD surface they would actually create any sort of pattern on them, you just had to supply an image, but at the moment I cannot recall any of them.

If you tried to do it without a grating pattern, you would need full knowledge of the camera data OR you would need to calibrate the camera yourself. Every sensor has a spectral response to light which you need to know in advance to convert some 45,62,186 to a wavelength. The spectral response depends on the image processing AFTER the sensor (and until the digital file) and of course the incident light.

So, to do spectroscopy directly on the captured images, you would need an LED source whose current is stabilised (to produce constant quality light), you would need to measure the "temperature" of the light produced, set the camera to manual, select an exposure setting and then use the sensor's spectral response for these particular settings to obtain the correspondence between RGB value and wavelength. Otherwise, you need to calibrate the camera yourself. This still involves the constant current light source but also light sources whose intensity and wavelength you have characterised very well (or patterns). It is doable, but not exactly straightforward.

How can I create an actual visible light spectrum?

You can use a diffraction grating as described above. You can also use one of the "old-school" transparent rulers. Their divisions are actually "etched" on the ruler so when you shine a thin strip of light on them at a very shallow angle, they act as diffraction gratings. You can actually measure the wavelength of a laser pointer very accurately in this way.

For example, let's say we use a phenolphthalein type of reagent such that, as the pH of a sample changes, the absorbance of particular colors changes accordingly and so the camera and image processing ultimately yields some values that can be calibrated to different pH values.

Why? This is already "implemented" and calibrated and standardised. Your local chemist probably stocks uranalysis kits. One of the strips in that kit measures pH. BUT! To get an accurate measurement off of the strip, you still need to make sure that you are photographing it under very well controlled light conditions (i.e. Current control light source, or flash photography but under the same conditions every time). Your image processing part could be matching the actual colour of the pH strip, to the "reference" colour chart that indicates which colour corresponds to which pH value. A very simple program for any platform (i.e. Octave, or Scilab).

Hope this helps.

$\endgroup$
  • $\begingroup$ Interesting! Yes a DVD with the foil layer removed looks like the easiest DIY method. Very simple. The only downside I see is that the spectrum magnitude will not be flat as it depends greatly on the light source. Is there even such a thing as a light source of all wavelengths and equal amplitude? Also it could be difficult to calibrate. One possibility would be to just compute the difference between spectra / images of a control sample vs the sample with the reagent or enzyme or whatever. Largely a software problem at this point. $\endgroup$ – squarewav Dec 24 '16 at 17:54
  • $\begingroup$ Thanks, you can upvote or accept the answer via the controls on the left if you felt it was helpful. Datasheets of LEDs contain their spectral response and with a constant current source you will be able to drive the LEDs without a change in 'colour' in the long term. Yes, subtracting is a very good idea. $\endgroup$ – A_A Dec 24 '16 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.