algorithmic modeling for Rhino
Dear Forum,
Been struggling with ways to limit number of colors (RGB) from Image Sampler.
Possible ways I've tried are:
1. Rounding individual R,G,B values (0 to 1) to specific increments. The problem with this is that when I bring the RGB values back together with Color RGB(f), the combinations create more colors than intended.
2. Using the the RGB values as XYZ values, and using closest point. The problem with this is that I can't figure out how to get multiple averages. Easy to get one with Average component, but more than one??
Feedback appreciated..
Cheers,
Ognek
Tags:
Hi Ognek,
the number of colours is limited already (there's only 16777216 different colours). You're clearly looking to project this RGB colour space onto a smaller set. But how do you define this set?
To compute multiple averages, you need to add all values together, then divide by the number of values. You should be able to get there with Mass Addition, List Length and Divide.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
David,
Thank you very much.
For the color thing: I'd like to limit the colors with a user input. Let's say "no more than 10 colors" means it would take all the colors from Image Sampler, and interpolate what those 10 would be based on how similar those colors are. Thats why I thought I could find multiple averages in XYZ, and use closest point tool, then convert it back to RGB.
Does this make sense?
Ognek
Ah, I see. So you have N colours and are looking to generate a set of X different colours (where X is smaller than N) that approximate N as best as possible? This is called Color Quantization (http://en.wikipedia.org/wiki/Color_quantization#Algorithms) and it's not particularly easy.
I'll have a dig around GDI bitmap color palette functions, see if there's anything already available.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Well your colours will be three-dimensional (R, G and B) so you'll need 3D voronoi diagrams.
I'm typing on this now but I think the job is far too big. I couldn't find a decent quantisizer in the .NET framework.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
baHahahahahahahaha!
© 2021 Created by Scott Davidson. Powered by