algorithmic modeling for Rhino
Hello everyone!
I'm new to grasshopper.
I want to sample this image and i need to transform each colour into a different sphere diameter.
So I have to create bigger sphere on the red zones and smaller on the blue. Of course on the colours between blue and red the spheres diameters have to be proportioned.
To do that the image sampler has to return some numeric values in some way so that I can apply them to the sphere diameter.
I tried out some ways but my problem is to assign a range of values to a specific colour.
I have to open this discussion because most of tutorials i saw about image sampler don't use rgba channel, can you help me please??
Thank you
Tags:
There's two major approaches you can take, and probably a whole bunch of alternatives I haven't thought of:
Neither of these approaches is particularly straightforward, but I recommend starting with the first as it a more direct algorithm (you always work with colours, making it more understandable).
The problem, as I see it, is mapping the colors to the sequence you wish, with red returning the largest value and blue the smallest. I tried several different approaches, including Color Hue instead of RGBA, dividing the domain into five ranges (colors) to 'ReMap', etc. Finally ended up with an expression to evaluate RGB values, but none of the methods really worked well. Used circles instead of spheres for better performance while testing.
I tried following David's suggestion #1, with only limited success. Still not happy with the mapping to correlate color to diameter... Instead of comparing RGB colors with 'FSim (Find Similar Member)', I had better luck converting RGB values to a single integer value (cluster 'ColorN' below), then using 'FSim':
But there are still anomalies. :( The 'colors' slider divides the gradient.
Here is an effort at David's suggestion #2, using RGB values as points (cluster 'ColorP') and distance. No "inverse-equation" involved. Instead of a gradient, I used five 'Color Swatch' components set to color values plucked from the original image using GIMP. They are used primarily to determine which diameter, from a list, is used for each color. The distance between each sample point and all five 'ColorP' points is computed, sorted, and the smallest values are used (color and associated diameter).
The blue group has a switch to choose "Sample" colors for all the circles, matching the image, or "Map" colors (one of the five plucked colors):
Sample:
Hi, sorry for the late reply.
Wow it is perfectly what I was asking for!! so thank you!
But I didn't understand for what you use the Sort component. I think I don't understand what this component does.
17 days... ancient history, my friend!
Sort operates on a list of numbers (nothing else, just numbers) and it will put them in a smallest->largest order. It has additional functionality though, in that you can use the number sorting to synchronously sort any other list of data.
For example imagine you have a collection of curves, and you want them ordered shortest to longest. Step one is to measure the length of each curve. You now have a list of numbers which is equally long as your list of curves, and with corresponding value ordering. These measurements are then sorted using the K input of the sort component while you plug your original curves into the A input. As the numbers are shuffled to go from lowest to highest, your curves will simultaneously also be shuffled in the same way.
Thanks David. I had to re-open the code to remember how I was using it here. In this case, I'm sorting the "distance" between the sampled RGB color (converted to a "point") and each of the five primary colors in my list. That sort by distance is used to sort the five colors and their associated diameters, then the first item in each list (corresponding to the shortest distance) is used for that "pixel" in the image.
I can't quite fathom the 17 day delay in looking for replies, though?
ok great, I understand. Thank you David, thank you Joseph!
Added by Parametric House 0 Comments 1 Like
Added by Gert Köhler 0 Comments 0 Likes
Added by Gert Köhler 0 Comments 0 Likes
© 2019 Created by Scott Davidson. Powered by