Point Colors: Import, Disply & Export - How?


(David Cockey) #1

I have “x y z r g b” .txt files of points with the “x y z r g b” values separated by spaces. The x y z values import with no problems.

How do I display the color of each point?

How do I keep the color associated with the point?

How do I export a “x y z r g b” file which includes the colors of the points after manipulating the points?


(David Cockey) #2

Example file:

SandersonPtTest.txt(377.0 KB)


(David Cockey) #3

Partial progress. I created a PLY file with the same points and colors. I can import it into Rhino with the points displaying their colors.

But if I try to export the same set of points as a PLY file I get a failure message. And if I export them as a .txt file only the x,y,z coordinates are exported.


#4

Hello,

Attached is an XYZRGB importer I wrote awhile back (Python script). I will try to hack out an exporter for you in a bit. You want the same format (space separated)?

Cheers, --Mitch

XYZRGBImport.py(973 Bytes)


#5

You can try this exporter on for size and see if it does what you want…

–Mitch

XYZRGBExport.py(1.6 KB)


(David Cockey) #6

Thanks! Both scripts work for me. One minor improvement if convenient would be to add the option of importing .txt files in addition to .xyz files. But only if convenient. I change the file extension on a .txt file to .xyz and it imported successfully.


(David Cockey) #7

Colors of points in a point cloud are lost when the point cloud is exploded.

I can now successfully import and display a point cloud with each point having an individual color using Mitch’s script or as a PLY file.

However if I explode the point cloud so that I can work with individual points the colors are lost and the points take on the color of the layer. Is / Should it be possible to explode the point cloud and retain the colors of the individual points?


#8

OK, new version of importer with .txt files as a possibility (I set that as default for you):

XYZRGBImport.py(1.1 KB)

It should, I think, but doesn’t look like it’s hooked up… pretty sure that too can be scripted until it gets implemented…

–Mitch


(David Cockey) #9

Thanks, much appreciated. Unfortunately the revised XYZRGBImport script isn’t working. It opens the file import dialog box but doesn’t see the .txt or .xyz files which are there.


#10

Weird, same thing here - it should work, but it’s not… hang on… does the attached work any better?

XYZRGBImport.py(1016 Bytes)

–Mitch


#11

Here is a script to explode a colored point cloud and retain the colors. If a non-colored point cloud is found, it will be exploded into points.

–Mitch

ExplodeColorPointCloud.py(729 Bytes)


(David Cockey) #12

Mitch, both revised scripts work as advertised.

However I found a new glitch. Use ExplodeColorPointCloud to explode a colored point cloud. Then use PointCloud to create a cloud with some of the points. The result of PointCloud is two point clouds, one has points with the original colors, the other has points with the layer color. I checked and PointCloud when used with ordinary points creates only one point cloud. That sounds like a Rhino problem, not a problem with your scripts.


#13

Maybe, maybe not… There was one problem with the original ExplodeColorPointCloud script, it left the original as well. It was late last night and I didn’t repost the correction. So maybe you didn’t realize the original pc was still there and included it with the new one… Attached is the revised version that deletes the original.

@pascal Although Rhino supports color point clouds in both opening and export, there is no direct way to create them without scripting. Also, for example if you have a colored point cloud and you use the “add” option in -PointCloud to add a point, it removes all the colors. (This is because under the hood it is creating a new point cloud, I think) So I hope that V6 will have color options added as command line switches to the PointCloud command. In the meantime, I also “reversed” the Explode script to allow you to directly create a color point cloud without having to export/import.

–Mitch

ExplodeColorPointCloud.py(881 Bytes)

CreateColorPointCloud.py(696 Bytes)


Texture mapped Pointcloud?
(David Cockey) #14

Mitch, it appears that you were correct about the origins of the second point cloud.

My sincere thanks for providing the scripts.


(Dale Fugier) #15

If you want to import a “point cloud with colors” file, you might consider writing a Leica-style PTS file (which is just a text file).

Rhino can read PTS files natively.

A Leica PTS file has the following criteria:

1.) The file extension is .pts.
2.) The first line of the file contains the number of points in the point cloud.
3.) The rest of the lines contain X Y Z I R G B values separated by spaces. The “I” value is an intensity value, which Rhino does not use. So just set this value to zero.

For example.

502
0 0 0 0 57 207 52
0.8165 0 0.577000000000001 0 81 146 224
1.069 0.7765 1.155 0 56 182 56
1.12 1.591 1.732 0 21 91 40
0.9671 2.393 2.31 0 25 85 253
0.6194 3.132 2.887 0 11 246 188
0.09898 3.761 3.464 0 191 72 199
-0.5616 4.241 4.042 0 25 1 223
-1.321 4.542 4.619 0 73 243 83
-2.131 4.644 5.196 0 22 117 36

Hope this helps.


(David Cockey) #16

Thanks for the reply. PhotoScan, the software I’m using to generate the point clouds, does not create PTS format clouds. However it does create PLY format files which I can use to import the point cloud coordinates and colors.