Grasshopper

algorithmic modeling for Rhino

Hi all,

I have a surface with a gradient of colors and I've measured the RGB values at various points across the surface.

What I would like to do is sort the sample points into four groups according to their color values.


Is there a way for me to take all the RGB values and reparameterize them into a list of floating values whose value is a product if its color in relation to another color along the gradient? Is it possible to do a conversion like this in a lossless way?

Maybe one color would represent 0 and one color would represent 10. All the RGB values would be given a new value between 0 and 10???

Any help appreciated.

Thanks

Views: 5731

Attachments:

Replies to This Discussion

RGB values are values in a three-dimensional space. You cannot losslessly convert each colour to a single number and use the differences between these numbers as a stand-in for distances in 3D space. The closest you can get would be to map your RGB space onto a Hilbert curve, but even then physical distances are only mostly preserved, in the sense that points in 3D space that are close together tend to be close together on the Hilbert curve as well.

You can of course compute the distance from all your sample colours to a single fixed colour and then sort your samples based on this, but I'm not sure how you're going to create your four groups based on this.

You can convert colours into vectors/points in Grasshopper without loss of accuracy, and you can compute distances between points and you can find closest point pairs. I think that is the best way forward.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Is it possible to create a color range? And then test whether or not RGB values fall within that range?

Like David suggests you could convert your colours to points. Which would all fall withing a bounding box defined by the two points -1,-1,-1 to 1, 1, 1. If you then generated a similar box for your range and used the Inside component you could get all the colours that fell within.

BTW the range does not have to be defined by a regular box it can be any closed BRep so you can have an odd shape

Thanks guys. I must say I'm unfamiliar with some of the tools in the image you posted. Could you maybe post the definition for me? Or just explain in more detail the way this works?

Thanks a million.

Sure thing. 

The above image was done using the latest version of Grasshopper 0.9.0006.

Most of what you see is for illustrative purposes only.

In the Top left hand corner are two components "Box 2 pts" and "Brep Wireframe". This is to show the 3D domain of the possible colours.

In the top Right hand corner is the "Sprites" component which is a new component found in the Vector Tab > Points Panel it shows the colours as fuzzy blobs in the Rhino Document.

In the bottom right hand corner is the Dash Pattern component this is to represent the Desired Range as a dashed line.

Now for the crux of the definition The range component is used to split a Range of 0 to 1 into 60 segments This is then put into the Gradient Component, which also has a domain of 0 to 1 (L0 to L1) so that we get 61 evenly spaced colours as the out put.

The colours then get converted to Points when put into the "Inside" component, Surface Tab > Analysis Panel.

The Brep used in the Inside component is a simple "Box 2 Pts" which has been created by combining the lower ends of you colour range into a point and the same with the upper range. (These are done with sliders and XYZ points.)

The results if the Inside component is a 0 and 1 for either in or out so When put into a Cull Pattern component you can select only those that lie within the desired range.

Thanks Danny. This was interesting and helpful.

Cheers

Hi

Just wondering... is there a kind of gradient component that does the oposite? sort of, you input a collection of colours, and if they fall into a threshold (that can be like the ones in the gradient component), the result would be this intervals?

Hi. I was wondering the same thing. Have you found a solution?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service