Searching \ for 'Detecting Color?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=detecting+color
Search entire site for: 'Detecting Color?'.

Truncated match.
PICList Thread
'Detecting Color?'
1998\09\28@231938 by Mark A Winters

flavicon
face
Does anyone know of a reliable (and inexpensive) method of detecting color
for input to a PIC? I need to be able to discriminate between small objects
1" to 2" in diameter which can be any one of four or five different colors.
Ideally, I'd like to also be able to tell what color the object is
regardless of how "shiny" or "dull" it may be.

Any ideas?

Thanks,
Mark

1998\09\28@235059 by mcoop

flavicon
face
Note - whatever sensor you end up using, you will need to tweak a bit for
different ambient light situations...

Use a near-white (omnidirectional) light source...

Take three photodetectors - belive it or not you may win with simple LDR's
for low freq work...(whatever you choose, you'll need to check their
wavelength sensitivity curves)

Correct each as appropriate with colour celluloid (lighting gels) to get
close to 3 colour vectors
e.g. Red Green, Blue  or CMY , or other 3 colours as appropriate to the
sensors being used...

You then have to correct the 3x channel gains (op amps , or offset  on the
A/D readings) to get a reasnable neutral balance of a 'white' sheet in the
lit area.

You may also map or 'matrix' these 3 channels in to RGB if that is easier to
work with.

Note that you'll need to do a lot more maths to correct for non-linear gamma
'tracking' in the range from white to black - that's when it becomes more
practical to buy the real thing and spend the money.

OTOH, if you are simply following 3 objects of sufficiently different colour
then this may work for you in 99% of cases.

Good luck
MC

{Original Message removed}

1998\09\29@001747 by Mark Willis

flavicon
face
Remote sensing applications.  Been a while.  To detect colors, you
need to calibrate relative brightness (for different filter opacities)
for different colors - you could do this on an assembly line with
something as simple as 3 (RGB) photo sensors looking at the same spot, &
some calculations, IF you only have certain colors available.  The basic
method is to figure out "Dark" versus "Solid" color, using a standardly
illuminated "white" target that has fairly even reflection vs. color
spectra (for this job sounds like you could use a clean white golf ball
as a test target, maybe?)  Then you can calculate the percentage of
intensity for each target you get (i.e. sample a target, if Red
Intensity >> Green Intensity and Red Intensity >> Blue Intensity, then
it's a red target, even though there may be some green intensity.
(Remember that the lamp you use, the test target, and the sensors you
pick, may not be linear with respect to the entire spectrum!)

 There are different color schemes for printing, like CMYK, but for
cheapest I'd go with maybe photodiodes or CCD arrays?  I'm not really
current.

 To "map" darkness of the target out of the picture, you basically use

 r' = R * r / (r + g + b)
 g' = G * g / (r + g + b)
 b' = B * b / (r + g + b)

 Where R, G, B are some good constants you calculate due to lighting &
filter transmissivity, so if you get off a white target: r=50, g=120,
b=100, you want something like r' = g' = b' (so R would be something
like 52, G something like 22, B something like 27, in this example;
obviously you want to try to use 16-bit integer math instead of floating
point math here - this is just a quick idea sketch!  I don't guarantee
my math even <G>)

 Then a bright green object would get r'=50, g'=1000, b'=70 or
something (higher values of all three if shiny, but with g' still
higher, lower of all three values if flatter in finish.)  You can then
decide which color the object is based on ratios of brightness, instead
of color saturations etc.

 Hmm, I thought MPJA (http://www.mpja.com) may have had a sensor like
this or some piece of associated hardware/filter/something?

 Perhaps less inexpensively:  One gent with the local robotics society
has been able to track a colored ball in real time on an NTSC camera for
robotic soccer, ignoring the robots, so I know it's possible to do this
sort of thing, on a 486 (laptop or desktop? Don't remember which, but
think Desktop), and pass the results to PIC-based robots.

 IIRC color values are separated from brightness values (but I'm not
really good at Video.)

 http://www.seattlerobotics.org, search for Soccer <G>  I looked,
there's just a meeting minutes on Dec '96, Bill Bailey & the Newton Labs
folks were the folks
{http://www.seattlerobotics.org/encoder/jan97/minutes.html}

 So I suppose you may need to search more.  I can ask if needed.
Someone at the meeting, 3rd weekend of next month, should know what's up
with that project <G>

 Mark, spam_OUTmwillisTakeThisOuTspamnwlink.com

Mark A Winters wrote:
{Quote hidden}

1998\09\29@004120 by ken

flavicon
face
Spectrograph?  A mass spectrometer, right?  Nahh, that would be to easy ;-)

Ken

At 09:09 PM 9/28/98 -0600, you wrote:
{Quote hidden}

1998\09\29@091322 by Peter L. Peres

picon face
On Mon, 28 Sep 1998, Mark A Winters wrote:

> Does anyone know of a reliable (and inexpensive) method of detecting color
> for input to a PIC? I need to be able to discriminate between small objects
> 1" to 2" in diameter which can be any one of four or five different colors.
> Ideally, I'd like to also be able to tell what color the object is
> regardless of how "shiny" or "dull" it may be.

The previous posters have pointed you in the right direction, but I'd like
to add a few details:

1. color filters are expensive. Therefore the third color filter can be
missing, giving full luminance information. The third color (usually
green) is obtained by matrixing the luminance (Y) and the red and blue
signals (R and B), i.e. G=Y-0.3*R-0.3*B (you can use other coefficients,
f.ex. those used in NTSC TV).

2. If you can afford to control the light intensity in real time then you
will likely get away with much cheaper sensors. In particular, the Y
signal can be used to generate feedback. This removes most gamma and
linearity related problems that someone else has pointed out. Getting rid
of ambient light is important in this case. A solid state lamp looks good
for this (many white leds in a box - available from led makers - e.g.
from Mouser I think), as it should not shift its color while being
controlled in intensity. For a large (mains powered) light you need a
mechanical iris or linear shutter to achieve this (expensive and fragile).

Inexpensive CdS photocells should be usable for this, followed by a simple
DC amplifier. It all depends on how accurate you want to get. Try to
determine the required color contrast to discern your colors by looking at
a video (taped ?) picture of the samples (all together) in a vectroscope
or color analyzer. If the dots are far apart, it's easy, else, you will
spend money ;). A vector scope should be available at least in a better
VCR repair shop or video (editing ?) studio near you.

Note that it is important to get all the sensors to read the incoming
light coming from the same angle. Patterned/ribbed surfaces can give a lot
of trouble otherwise.

3. To detect a color with such a setup, notice that Y >= {R,B} always (due
to lack of filtering on Y). This allows for a deliberate gain reduction in
the Y channel, to improve S/N on R and B. Then, you scale the 3 signals
after obtaining G:

G = Y - 0.3*R - 0.3*B (Note: 0.3 includes the filter attenuation ;)
BASE = MIN(R,G,B)
SCALE = MAX(R,G,B) - SCALE
R1 = ((0.3*R - BASE) * MAXCOUNT) / SCALE
G1 = ((G - BASE) * MAXCOUNT) / SCALE
B1 = ((0.3*B - BASE) * MAXCOUNT) / SCALE

(Note: MAXCOUNT is an arbitrary positive integer chosen to give sufficient
resolution for your color selection in the discrimination table. For your
numbers, 3 bits per color may be enough - or not - see #5)

4. Match R1,G1,B1 against a 3d range-table (cloud table ? - how do you
call such a thing - a 3d cartesian range-plot). This is large and I don't
know how you can fit it into a PIC, unless you do some serious
optimization for the calculus to yield a strict range.

5. If you restrict the input colors to the 3 primary colors and their 3
complements you will have a relatively easy job at 4, there being a
formula that can replace the table. There are also formulas for other
color combinations.

hope this helps, and sorry for the longish post.

Peter

1998\09\29@091700 by Mark A. Corio

picon face
Mark,
We have been in this area for some time.  If you can control the ambient
lighting situation an easy way to descriminate color is to use multiple LEDs
for illumination, each of a different wavelength. The absorption of each color
illumination is a direct indication of the percieved (i.e. reflected) color.
By doing appropriate ratioing of the colors recieved (to account for sensor
sensitivity, surface roughness, etc.) you can easily determine between a
handfull of colors. The sensor can be a single photodiode connected to the ADC
input of one of the so-equiped PICs.

Mark A. Corio
Rochester MicroSystems, Inc.
200 Buell Road, Suite 9
Rochester, NY  14624
Tel: 716-328-5850
Fax: 716-328-1144
http://www.frontiernet.net/~rmi/
****** Designing Electronics for Research and Industry ******

In a message dated 98-09-28 23:21:30 EDT, you write:

<< Does anyone know of a reliable (and inexpensive) method of detecting color
for input to a PIC? I need to be able to discriminate between small objects
1" to 2" in diameter which can be any one of four or five different colors.
Ideally, I'd like to also be able to tell what color the object is
regardless of how "shiny" or "dull" it may be.

Any ideas?

Thanks,
Mark
 >>

1998\09\29@103552 by RCGipson

flavicon
face
i agree with mark corio.  while in college, i talked a robotics prof
into allowing me to bypass part of the course with a "complicated"
project.  i would sort ping pong balls by color!  well, anyway, i used a
small robotic arm to pick up a ball and place it in front of a
photodiode.  the photodiode was connected to an op-amp and adc.  i was
very easily able to distinguish between the three colors and put them
into the correct "bins".  the project was used to amaze the "visitors"
during an open house.

i determined the range of readings for the various colors and acted
according to the voltage from the diode.  the pingpong balls i sorted
were all the same color of red for instance.  i did not have to deal
with different hues of red.

roger

1998\09\29@143140 by Mark Willis

flavicon
face
I been out-devioused;  I *like* it!  Especially with the modern
High-intensity Red, Green, and Amber LED's (Rat Shack sells those, among
others), and you could use a PIC-controlled analog switch array to swap
between trim pots used for calibration of the Op-Amp following the
photodiode...  Or (perhaps better yet!) to PWM the analog switch with a
single fixed resistor <G>

 Minimizing parts count even further is good <G>

 Mark

Mark A. Corio wrote:
{Quote hidden}

1998\09\29@192852 by dporter

flavicon
face
If you are trying to ignore shininess or dullness, you should arrange the
geometry of the receptor to avoid the specular or glancing reflection of
the light source.  This component to the reflected light is exactly the
same color as the source.(!) If you exclude this component from the
receptor, you'll have the reflected color of the object left to quantize.

Dave Porter
.....dporterKILLspamspam@spam@voicenet.com

----------
> From: Mark A Winters <markwintersspamKILLspamWORLDNET.ATT.NET>
> To: .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
> Subject: Detecting Color?
> Date: Monday, September 28, 1998 11:09 PM
>
> Does anyone know of a reliable (and inexpensive) method of detecting
color
> for input to a PIC? I need to be able to discriminate between small
objects
> 1" to 2" in diameter which can be any one of four or five different
colors.
> Ideally, I'd like to also be able to tell what color the object is
> regardless of how "shiny" or "dull" it may be.
>
> Any ideas?
>
> Thanks,
> Mark

1998\09\30@115650 by Reginald Neale

flavicon
face
To supplement Dave's suggestion, if you don't have any control of the
lighting geometry you may be able to use a polarizing filter to reduce the
specular component. The penalty is that transmission is typically less than
50%.

{Quote hidden}

1998\09\30@155747 by Pedro Barrios

flavicon
face
Hi there,

There was an article in Electronics now about 1 to 2 years ago
describing the construction of a color detection machine but it
hooked to a computer. It worked pretty well (after some
corrections to the original circuit) and it could store
up to a thousand colors. Maybe you could modify that design to
suit your needs.

Regards,

Pedro




At 03:53 PM 9/30/98 GMT, you wrote:
{Quote hidden}

1998\09\30@190027 by paulb

flavicon
face
Reginald Neale wrote:

> To supplement Dave's suggestion, if you don't have any control of the
> lighting geometry you may be able to use a polarizing filter to reduce
> the specular component. The penalty is that transmission is typically
> less than 50%.

 Not typically, *always* - by definition!  If it were greater than 50%
it wouldn«t be a polariser.

 Note that a polarising filter must be aligned to match the angle of
the specular reflection, that is, to match the light source.  If you get
it wrong by 90¡ or the light moves by this amount, it actually
*enhances* the specular reflection.

 OK, I guess you know all this.
--
 Cheers,
       Paul B.

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...