Grasshopper

algorithmic modeling for Rhino

Getting individual R, G, or B values from an image...

Dumb question here, but if I have an image sample with, say a 10 x 10 matrix of points fed to it - domain 0 to 1 in both directions - I get a list of RGB colors out in the panel. 

As these look very much like point triplets, first I thought I could use the point decompose component and extract just the list of R valued for each sample.  Doesn't work, however, I get some odd values like -1 where the color is RGB (0,0,0).

Using the ARGB split component everything is proportionally right, but all is in a domain from 0 to 1, I need to multiply by 255 to get the individual values as I recognize them...  No problem there, but why does the panel show me the 0-255 domain RGB while the ARGB split gives me domain 0-1?

Thx,  --Mitch

Views: 1972

Replies to This Discussion

Hi Mitch,

When you convert a colour to a vector (or point) the channels are mapped from 0~255 to -1.0~+1.0

I chose this mapping behaviour so that all unitized vectors (no matter the direction they point in) can be converted to unique colours (barring of course accuracy loss due to rounding). So yes, black (0,0,0) becomes a point at {-1,-1,-1}. White will be {+1,+1,+1}. 50% grey will be {0,0,0}.

Split ARGB uses floats rather than integers because of the other colour types. This may not be a good reason. I added a component option, but the default is still floats.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

OK, thanks for the explanation David!

--Mitch

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service