go_away

### Author Topic: Color Sensor & Signal Amplification  (Read 415 times)

0 Members and 1 Guest are viewing this topic.

#### gpeters

• Beginner
• Posts: 1
##### Color Sensor & Signal Amplification
« on: June 04, 2013, 06:47:05 PM »
First off, I'm completely new to electronics (Just your standard software engineer)

I'm working on a color sensor where I'd like to provide better visibility to the color I am sensing. I'm using an Red, Green, & Blue high powered LEDs.

1) Will amplifying the signal provide better distinguishability of the color being sensed via voltage?
2) Will amplifying the signal also amplify any noise on the signal? if so, will amplifying also add additional noise?
3) I know ambient light will affect the readings. Will a linear light to frequency sensor help?

To calibrate my sensor, I'm wanting to use black paper for low voltage and white paper for high voltage readings.

1) Since every LED is not made the same in terms of brightness, will adding a trim pot to each LED assist me in normalizing the voltage?

For example, if I get a reading of on my ADC of 15,43,33 (RGB respectively) when reading black, can I normalize all three to 10,10,10 to account to brightness?

#### jwatte

• Supreme Robot
• Posts: 1,343
##### Re: Color Sensor & Signal Amplification
« Reply #1 on: June 05, 2013, 10:03:35 AM »
If you're a software engineer, have you worked through general graphics color theory? Played around with Photoshop a bit?

Amplification will multiply the input signal. If you have a range problem, where your min/max values are, say, 3 and 22, then amplifying by 20 dB (multiplying by 10) will make your range be 30-220, which may be better suited to the particular ADC you're using. Yes amplification will amplify all parts of the signal, which includes "noise" (the electronics doesn't know what you'd consider "noise" and what you'd consider "signal.")

If what you want to do is get stronger color (less "muddy") then you can more easily compensate in software. Same thing for calibration. If you calibrate black as 10,10,10 and white as 220,220,220 or whatever, using scale-and-offset, then you're good on neutral. If you don't understand how to calculate scale-and-offset (out = in * scale + offset) then work through the match on paper and try it in Photoshop until you get it!

To "intensify" the color reading, you can use this algorithm:

Code: [Select]
`avg = (red + green + blue) / 3;red = avg + (red - avg) * intensity;green = avg + (green - avg) * intensity;blue = avg + (blue - avg) * intensity;red = clamp(red, MIN_VAL, MAX_VAL);green = clamp(green, MIN_VAL, MAX_VAL);blue = clamp(blue, MIN_VAL, MAX_VAL);`
This assumes floating point values or other values with a range larger than the [0..255] range of the input values, as intermediate values may go outside this range.