I am trying to create a script (having very little knowledge of grasshopper) with a photogrammetry scan. Based off of the RGB values of each point I want to 1. group them and 2. modify and change their colours.
If someone could help with the script or point me in the direction of where to look that would be amazing!
Whoa! 18.2 MB!! I can open the file in Rhino and see that the tree (sideways) is 1 point cloud with one million points when exploded!!! But don’t know how to access those colors in Grasshopper? Looking…
I spent way too much time struggling with Rhino APIs and Python and not enough time on Google.
So I have code now that outputs all points and their colors. Trying to do something useful with it but a million points is a HUGE data set. Have you got something smaller we can play with until this works?
I didn’t know a text panel could hold a million colors.
P.S. Can you please elaborate on how to group the colors? Do you want to “round off” colors to ranges of 25 red, 25 green and 25 blue values?
I’m still refining what I have and would like clarification from you before I post the code.
For each point, I’m splitting the colors into RGB values and sorting them, using the highest R, G or B value to categorize them. By this method I count 544618 blue points, 406564 green points and 48974 red points. (see third image below)
Then I have a slider (5 to 30) that divides 255 (the max value of RGB) into ranges (domains) for rounding off color values, effectively reducing the number of colors.
It’s slow for a million points; Sort and Find Domain take 1.7 minutes each for 3 million values (one million points times three color values each).
I’m using Custom Preview to re-color the points instead of modifying the point cloud in Python, which is also somewhat slow and perhaps alters the results?
Well, there are all kinds of games that can be played with colors, but as I like to say, this is your art project. I’ll post the code I have, knowing there are more ideas to explore. You need to right-click the Cloud_ID component (cyan group) and then click the point cloud in Rhino.
The purple group at the top limits the points used unless you choose ‘All’ in the blue group FILTER. WARNING!! ‘All’ is slow!
That table doesn’t have many colors and will fall over with only two legs?
I forgot to mention that the disabled Preview component on the right, connected to the three color swatch components… well, it’s difficult to explain and I wanted to fix that before posting but… The sequence of colors depends on the point cloud, as indicated in the text panel above it showing the count for each color. The table shows this:
Color: R = 324888
Color: B = 1125
Color: G = 631
So the colors need to be connected to Entwine in that same sequence: RBG (God bless her soul), not BGR. Crude, I know, but it’s bed time for me.
This code is a first draft, many things could be changed.
P.S. The points displayed by Custom Preview are definitely and obviously larger than the points in the point cloud, so any color games should modify the point cloud via Python. Which might get weird, modifying the source data unless a copy is made? I know nothing about point clouds.
When using Volvox, you can import a smaller subset of the point cloud to make working with the cloud faster until you need all the points. Volvox also lets you extract the colors by deconstructing the cloud with DeCloud component. Once you have the colors, you can tint them all at once (C# component uses GH_GraphicsUtil.BlendColour).
I moved the points an arbitrary 5 units in both X and Y so the new point cloud doesn’t overlap the original.
I can’t replicate that observation this morning.
I replaced the Cloud_ID component (cyan group) with a command line prompt:
The only clue that you have selected a point cloud is the prompt disappears. Terrible UI because there is a long wait before anything else happens. Be patient. I added an ‘OnOff’ switch to the getPtCloud component (the original Python) so toggling that switch (off then on again) will re-display the prompt to “Select a point cloud:”
I disabled most of the white group because it was slow and not required for the yellow group. point_cloud_2022Oct23a.gh (27.3 KB)
I don’t know if this is off topic but …
Have you tried using “Cloudcompare” , it is free software that is very good at classifying pointclouds.
It should be able to do a colour separation.
I use it for processing LIDAR landscape data.
I have worked with point clouds up to 30Gig, it is very powerful.
This version has cosmetic changes that don’t address your primary goals (above) but might be general purpose enough to be useful for other GH projects.
The pink group at the top-right uses Galapogos to find a minimum bounding box for the point cloud. When the solver is done, click the Data Dam to pass the results downstream. As always, Data Dam leaks on startup, meaning it passes data without being clicked.
The teal-colored group below it uses the minimal bounding box to orient the point cloud vertically at the origin.
Fixed the color issue in the disabled white group. No need to manually reconnect color swatches.
Select Point Cloud (then wait patiently)
Start Galapogas Solver (wait patiently)
When Galapogos is done, click Data Dam (again, wait patiently)
getPtCloud takes ~18 seconds for both the table and the tree, according to the profiler. FDom(Find Domain) in the yellow group takes 1.9 minutes for the tree, 32 secs. for the table. Sort in the white group takes 1.8 minutes for the tree. It is disabled by default.
I see nothing proprietary in anything posted on this thread. You haven’t posted any code at all and are free to remove the two E57 pointcloud files from your posts. There are plenty of other examples that anyone is free to use instead: