3D Colour space plugin?

Hi everybody,
is there any grasshopper plugin that allows me to draw a 3D colour space in rhino in form of a point cloud? or something similar? I’d like to draw colour spaces in rhino and extract points from those spaces based on proximity to other points.

If you want to suggest other software or web apps to do this task let me know!

Same thread:

Adapted from this, January 2018:

2 Likes

Wow! I even looked for it in the forum and I couldn’t find it! thank you very much I’ll take a look at it!

Just a note on this, in the last years it happened I had to work on a few projects that involved color quantization, and if you want to use euclidean distance (let’s say Closest Point) to find the closest match for a given color from a smaller palette then, in order to simulate the human eye behavior, RGB color space is very much not the best option

if possible go for LAB color space for those kind ok proximity match

1 Like

yep, that’s exactly what i wanted to do, my plan was to use oklab space, but I still have no idea on how to place it in rhino 3D space, do you have any resource that deals with it?

I remember using some Python library to handle the RGB to LAB color conversion, probably was this one (but it’s standard CIELab, not OKLab, don’t know about that):
https://python-colormath.readthedocs.io/en/latest/index.html

once you get Lab values for each color, you can split the channels and use Point XYZ (L, a, b) to get their 3D representation

for instance, something sketched very fast, and blindly trusting the code from the above link:

generally speaking, not only euclidean distance between different colors is more reliable in Lab than in RGB color space, but also clusterizing colors (for instance k-means) yelds better results

this def will work on R8 only, and will take maybe a couple of minutes at very first launch because it has to download the colormath Python library

hopefully_this_does_RGB_to_LAB.gh (37.7 KB)

3 Likes

That’s super helpful! thanks!

it just happened today I had to exhume those buried rgb/lab experiments
this topic came to my mind and I thought of dropping a brief visual-note

after sampling image-pixel colors in a grid, which results in a list of RGB, K-means clustering was used on both the RGB color list and the very same color translated into LAB to find 20 clusters

example of LAB k-means clustering result

then, each grid point was given the color of the average of the respective group, and here is a result

[ image of Angel Oak Tree from this website: 10 of The Most Magnificent Trees In The World ]

as k-means method implies a random starting position (seed) you can run the algorithm n times and get n different groupings, but the results are somehow similar among each other

this said, it also depends on the image you are working on, its lighting, color variation etc…
but generally speaking, for most seeds my eyes prefer the result calculated through LAB color space

but if you have an image and you want to reproduce it using a given, fixed, limited palette of different colors that have already been chosen ahead (which is more or less what I’m working on now), in that case:
a) you don’t want to get “islands” of the very same color, even if that particular color is the closest you can get from your available palette, and
b) you want to use as many palette-available-colors as possible, despite some of them being very far away from the colors in your image…

so I’m watching this :upside_down_face:

to get this:

not exactly the result I want :smiley: but I’m on the good way

2 Likes

Man you’re doing some interesting stuff!!!

1 Like


hopefully_this_does_RGB_to_okLAB_maybe.gh (22.1 KB)

Hi,
I’ve tried implementing the OkLAB converter with python script and this python library: GitHub - colour-science/colour: Colour Science for Python

it kinda worked, but the result oklab 3D gamut is very deformed and I don’t think it’s correct especially because there is a big gap between blue shades, anyone can help me understand what did I do wrong?

attached you can find the GH script.

To install the library I’ve located Rhino python folder and I’ve installed the library via powershel by typing “pip install --user colour-science”, but this is not really convenient, if you have a better way to do it let me know!
I had to change windows environment variables to make windows able to see rhino python as explained here: https://www.youtube.com/watch?v=dj5oOPaeIqI

PS, I’ve also tried to convert from XYZ to oklab with the help of CHat GPT which didn’t require any plug in and gave me very very similar results to the plugin I’ve used (just a tiny bit translated) you can check it by turning of the relative preview node.