|
Page 1 of 1
|
[ 3 posts ] |
|
Finding closest color (beyond basic colors)
| Author |
Message |
|
Philipp
Rookie
Joined: Tue Nov 22, 2011 10:45 am Posts: 12
|
 Finding closest color (beyond basic colors)
I have 12 Duplo bricks in different colors and would like for the ColorSensor to tell which is which with good probability. Finding base colors like Blue, Red or Yellow is easy enough, but I would like to know the best way to find out other colors, like "light blue" or "black" (I even have a transparent Cyan one, but let's disregard this for now). My current algorithm notes all brick colors (as recorded with the color sensor), then during program run converts the current RGB into Hue Saturation Value, and then does a closest match as below: This works well for some bricks, and not so well for others (e.g. it can't really differentiate betwen red and brown). Is there a better way? Thanks!
|
| Wed Nov 23, 2011 6:37 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 Re: Finding closest color (beyond basic colors)
Which sensor are you using? The LEGO one or the one from HT?
The trouble with red and brown is that they're way too similar, depending on the light that is being reflected on them. Maybe you need to tighten up your distance function a bit or have more control over the light that is being reflected on the bricks.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Thu Nov 24, 2011 2:35 am |
|
 |
|
Philipp
Rookie
Joined: Tue Nov 22, 2011 10:45 am Posts: 12
|
 Re: Finding closest color (beyond basic colors)
Thanks Xander. I'm using the Lego NXT 2.0 pack's color sensor. I'm also using a bit of your HSV conversion code, I noticed your work and tutorials in a lot of places and it's very helpful!
Beyond just Brown vs Red, other colors also cause me trouble. For instance I got dark gray, light gray, and black, yet the white table is also sometimes triggering one of those. I got a light green and light blue, which is also hard to differentiate. I'll try fine tune my approach and also see if I can find other, less reflective material. If all else fails, I might look into using two-color codes, e.g. "blue then yellow" would mean one thing, "red then green" another thing, just using the base colors red, blue, yellow and green, which (while not quite what I had in mind) would give me the 12 possibilities.
|
| Thu Nov 24, 2011 3:18 am |
|
|
|
Page 1 of 1
|
[ 3 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 5 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|