PDA

View Full Version : Parsing spaces in return from image.rbg()



walfridson
08-03-2009, 11:10 AM
So I need to read pixels in an image from the image agent.

I'm getting RGB with image.rgb()
The return from rgb() is for example "1 1 1". Spaces seperating the values.
I would now like to break these RGB into seperate values.

I'm trying to do this with parse but it's not working great.


RGBreturn = image.rgb(1,1);
RGBParsed = parse(" /t",RGBreturn.asStr());
info(RGBParsed[1]);
This gives me "111"
If I however do this:

RGBParsed = parse(" /t","1 1 1");
info(RGBParsed[1]);
It gives me "1"

Any ideas?

Can't find any ways how to step each char in the string...

dpont
08-03-2009, 12:31 PM
isn't it an array of 3 floating color values?

Something like,
RGB = image.rgb(col,row);
r = RGB[1];
g = RGB[2];
b = RGB[3];

Denis.

walfridson
08-03-2009, 12:36 PM
argh, i'm on a stupid roll.

thanks denis

Blochi
08-16-2009, 12:06 PM
or you can use the shortcut:

(r,g,b) = image.rgb(col,row);