Grouping RGB colors

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc

Moderators: roger, 99jonathan, imaqine

Grouping RGB colors

Postby ecrin » Tue May 22, 2012 10:08 am

Hi
I am trying to write an extension in netlogo for Nxt brick . To connect the brick , I am using Lejos. I have a problem with color sensor. I want to write a simple method which returns sensor color as a number such as yellow : 1, red :2 etc. But sensor motor always returns different RGB colors on the same surface. For example I put it over a yellow paper , rgb colors are : [236 189 104] ,[247 202 108].. if it was returning unique RGB numbers for same surface colors, I would classify them according to RGB colors range and give a unique number for each color. Do you have any idea how i can do it ? Also , it won't run on different surfaces. only doing this for my paper colors( yellow, blue, green) will be enough for me. Thanks.
ecrin
New User
 
Posts: 3
Joined: Tue May 22, 2012 10:03 am

Re: Grouping RGB colors

Postby gloomyandy » Tue May 22, 2012 10:20 am

Which methods are you trying to use? Sounds like you need to be using getColorID:
http://lejos.sourceforge.net/nxt/nxj/ap ... ector.html
Note however that this only really works for the standard Lego colors...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Grouping RGB colors

Postby ecrin » Tue May 22, 2012 10:48 am

Thank you for the answer. But I want to write colorID method myself. Because as you said , sensor is numarating exact ,limited colors. I am using some different color papers and by using their rgb colors I want to give them numbers.I really didn't understand why each time sensor motor returns different numbers, is it because of light or anything else?
ecrin
New User
 
Posts: 3
Joined: Tue May 22, 2012 10:03 am

Re: Grouping RGB colors

Postby gloomyandy » Tue May 22, 2012 12:33 pm

Well in that case you will have some more work to do! Basically pretty much all sensors will return some variation in readings, then you have to add in any variation due to changing light levels and the actual surface you are reading from. Even things like the 50Hz flicker of mains powered lighting can easily be seen in the sensor readings. So basically you will need to process the readings a fair bit. To get an idea of the sort of thing you may need to do take a look at the code (based upon the Lego firmware code), that performs the current color recognition...
http://lejos.svn.sourceforge.net/viewvc ... iew=markup
the readValue method at line 677 is the recognition code. Not however that it is using the raw readings, the values you are seeing may already have been processed to some extent. I'm not sure if the raw readings are actually available to you if your code is running on the PC...

Andy
]
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Grouping RGB colors

Postby ecrin » Tue May 22, 2012 2:16 pm

It is a bit more complex than I hope. But the code give me idea. Thank you for your helps
ecrin
New User
 
Posts: 3
Joined: Tue May 22, 2012 10:03 am


Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff