RGB to Grayscale with ShapeDiverImageSampler

Hi everybody,

I am doing a shapediver definition, in which basically from an input image I would like to get the grayscale at locations. The ShapeDiverImageSampler component, returns colors in RGB format.

I am then wondering how to convert these colors in grayscale. I am thinking about splitting the returned list into a tree such that each branch (corresponding to a pixel) contains three items (R, G and B) and then use a formula (like L = 0.2125R + 0.7152G + 0.00722B) to convert the colors into grayscale. But as any shapediver definition should be optimized for speed, I am wonder if there is a faster way.

Thanks in advance.

1 Like

Your method will work, but it might be faster using the attached script. You can modify the formula in the script, it is a little different than the one you wrote above:

grey_scale.gh (4.8 MB)

1 Like