0

I am hoping I could get some help developing a an idea I have for archaeologists/soil scientists using an arduino and the TCS3200 colour sensor. The idea I have is a simple device which can determine munsell colours with more accuracy and speed. The current conventional method is to use colour chips/swatches found in the Munsell system booklet and match them as close to examples of sediment/soil found at archaeological sites. The problem with doing this method is that it is highly subjective, and time consuming.

My idea is to use the Adafruit TCS34725 to read and detect the RGB colour of the sediment (in the RBG colour space) and convert the data into the Munsell System. I have all the data of what RGB ratio corresponds to each Munsell colour -- which I have downloaded from this site: www.cis.rit.edu/research/mcsl2/online/real_sRGB.xls

My problem is that when I use the sketch provided, I can not figure out how to use the "if" statement to "Serial.print" what the munsell colour corresponds to the RGB colour detected by the sensor.

My ultimate goal is to modify the colour view sketch here see: colorview I would like to keep the everything provided but change two things, I would like to convert RGB into Munsell using the data provided by the RIT link and also add a screen and button to start the read process and display the colour.

If some one would be willing to help me that would be great!,

  • Maybe use the routines at cs.rit.edu/~ncs/color/t_convert.html – Dave X Apr 20 '16 at 21:07
  • That would be a helluva lot of IF statements. What you need is a Look Up Table (LUT) - i.e., an array in PROGMEM. – Majenko Apr 20 '16 at 22:03
  • Yeah, I figured there would be a better way than using the IF statements, However I am not sure if I can generate the LUT with the sensor. What I might do is use a python program that preforms the conversions. And input the data from that using my raspberry pi. – Cory Vickruck Apr 21 '16 at 2:18
  • 1
    Before you even think of implementing this on an Arduino, you should set up a system where the Arduino reports the RGB readings over a serial link to an easily monitored, size-unconstrained, "thinking in code"-friendly piece of experimental software running on your PC. Only move an algorithm to the Arduino after you have a good idea that it is sound. – Chris Stratton Apr 21 '16 at 15:56
  • Which if statement? Your link points to the github repo, not to a particular line. – JayEye Apr 21 '16 at 16:46
1

I have some thoughts on your task. First of all colorimetry is a science on its own. I know people working in this field for decades with equipment costing many millions of €. They all share some basic wise words. One is: "Because we all see colours we think measuring colous is an easy task. The opposite is true. Many of the best colorimetrists are colour blind." One second is: "Without light there is no colour". I will write on this later.

Colorimetry in fact is a complex matter. Between a colored piece of stone and a numerical value normally lie a lot of transformations and convolutions. And inbetween there are also lurking many error sources.

This said, I'm sure it will be possible to produce somewhat acceptable results with your sensor. Provided you do a proper calibration and add a calibratable light source.

Speaking of light source. A piece of stone can only reflect incident light (except some uranium/radium salts, you don't want to deal with). Pigments are basically LTI-systems (aka passive filters). This means they can only reflect wavelengths which are present in the incident light. And the will reflect a well defined and individual proportion of each wavelength regardless the luminous flux of the incident light. This means, if your incident light contains nearly no blue light then the stone or whatever you want to examine will reflect only the fraction of "nearly no light" it typically does reflect of any amount of blue light.

So the remission spectra of all pigments get shaped (multiplied) by the spectrum of the incident light. Your sensor sees only the reflected light and therefore will give totally different results for one and the same object depending on the incident light. Look up the spectra for daylight and incandescent light and think about the results of your sensor.

To make a long story short, you can only yield reproducable measurements if you supply your own light source along with the sensor. This is in fact the way all colour meters work. The only other way was to measure the full spectrum of the incident light. Reasonable portable spectroradiometers for this purpose cost 5000 €. So it's better to go for a light source :).

As they are rather affordable I recommend using LEDs to make up a light source for examination. But LEDs suffer from several drawbacks. They tend to change their output spectrum with their chip temperature and ageing processes. So you have to supply a proper calibration procedure for your measuring equipment. And you better do the calibration sequence before every measurement.

You then have to design an apparatus which allows the light from your LED fall onto your samples (stones, sediments or so) but prevents other scattered or direct light to enter your sensor. Otherwise all measurements will be crap.

While this is not a direct answer to your question, I think the topic is important enough to write an elaborate pamphlet.

Update

Now some more words more closely related to your problem.

In general loading a huge excel table into your arduino is not necessarily a good idea, even if a big "if"-code array was possible. Storage is scarce on this platform.

If you combine a lookup table with interpolation, you can save much space. You would have to omit 90% of all datapoints and estimate all in between when measuring. Still the table will be rather big, because you have three degrees of freedom.

Another drawback of big tables and LUT with interpolation is, that it makes calibration difficult. Normally, when you calibrate your sensor, you have to adjust the parameters along the calculation. If you rely on a table, you have to exchange the whole table, regardless if it is something like that excel thingy or a condensed lookup table.

If you go for an analytical solution, as suggested in one comment, the number of parameters you have to update after calibration reduces drastically. Effectively you have to adjust some factors and offsets in the equations for this problem. Of course you will have to learn the ropes of the photometric equations, but you will have to do that anyway, I think.

Some more words on the design of your appartus. Your idea of a cylinder in front of your probe is good. I recommend to fit it with a rim of black foam rubber, so you can seal light coming from outside. And you have to paint the inside of your cylinder as black as you can. See the interiour of a camera objective for reference.

If it is white you will have multiple reflections and multiple filtering which deteriorates your measurement results vastly.

  • Thank you for your help, I am fortunate that the sensor that I am using comes with its own light source :). So I think the design I am working up in my head is a tube around where the sensor will be placed, I am hoping that I could then cover the sample/rock leaving only the LED light falling onto the sample. The sensor has a built in IR filter as well as the ability to detect the temperature of the ambient light reflecting off the sample. – Cory Vickruck Apr 21 '16 at 22:07
  • I agree that it is a difficult science which I why I am hoping to find help on this forum. I am glad that there are people kind enough to offer opinions/comments on how to achieve this goal I have. I am looking at developing more tools for archaeologists to use in the field that are both cost-effective and simple to operate while providing accurate data. In archaeology I find that the methods we apply to answer particular questions could use improvement. Once, again thank you for your suggestions hopefully I can keep everyone updated on my progress. – Cory Vickruck Apr 21 '16 at 22:17
  • I spent some more thoughts on your problem, let's see if we can get that going. Some of the problems perhaps might fit better into another SE community – Ariser Apr 22 '16 at 14:55
  • I have been working on a python code that takes a user input defined input and converts it into munsell using a if/elsif print statement. It is a bit impractical, doing it this way but it works. I know that there is a python library that can work with excel files, and I am currently looking at using that as an alternative to printing 1000+ esif statements :p. I am thinking that the arduino may not be the best device to use for this project. I don't think it would have enough memory to run the program and run an small lcd. I am currently in the process of looking at drivers for the Rpi – Cory Vickruck Apr 22 '16 at 22:09
  • The Arduino is able to do that task. You would need only roughly 6 (!) if statements an a while-loop to find corresponding munsell values for a given RGB from this table. Your only task was, to transform the table to something usable written in C and write a code to find the values in the table. I take bets it is possible with less than 50 lines of code. Moreover I strongly recommend to solve this problem analytically otherwise you will get into trouble if you want to calibrate your system. – Ariser Apr 24 '16 at 8:21

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.