PCD three channel color data

Hi, I am scanning my environment using my IPhone, and I get a .las file through export
and converting it to pcd file using PDAL CLI, I get a output file with red green and blue as separate colors.

If I try to load this file, I don’t see the color, but it exists, also I tried to read the below point cloud library logo PCD file, it contains the color data in single channel format (“rgb”).
pcl_logo.pcd (309.2 KB)

Is there any way to convert this three channel RGB into a single channel color data?
Or can I configure the ThreeJS PCDLoader to load the pcd file using the red green blue colors

I went through the lastools for lascolor for any hint, found out it can convert the single channel RGB data into three but not vice-versa.

I also tried to write a python script to convert the colors myself , but the conversion was inaccurate to most extent

Any help will be much appreciated.

PS: I cannot share the las file due to NDA

Hard to say without seeing any code or data.
This is kinda like calling your mechanic on the phone and saying your car is making a clicking sound, and then asking for a repair estimate.

That said… combining separate r,g,b, channels into an rgb image sounds pretty straightforward.
Load them up… get the pixel data out, and combine them in a loop…
Are you also reading the positional data succesfully?

My bad, here’s the sample pcd file with multiple color channels, which is obtained by using pdal translate over a las file:

VERSION 0.7
FIELDS x y z intensity returnnumber numberofreturns scandirectionflag edgeofflightline classification scananglerank userdata pointsourceid gpstime red green blue
SIZE 4 4 4 8 8 8 8 8 8 8 8 8 8 8 8 8
TYPE F F F F F F F F F F F F F F F F
COUNT 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
WIDTH 11991043
HEIGHT 1
VIEWPOINT 0.0 0.0 0.0 1.0 0.0 0.0 0.0
POINTS 11991043
DATA ascii
-12.22 21.68 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 19018.00 17219.00 16191.00 
-12.24 21.69 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 16705.00 14392.00 13364.00 
-12.27 21.69 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 17990.00 16191.00 15677.00 
-12.29 21.69 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 22102.00 19789.00 19532.00 
-12.32 21.69 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 23387.00 22102.00 21331.00 
-12.34 21.70 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 20046.00 18761.00 18247.00 
-12.47 21.72 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 19275.00 18247.00 18247.00
-12.49 21.72 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 20303.00 19532.00 19532.00 
-12.51 21.73 -0.96 0.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 19275.00 18247.00 17733.00 

expected output:

# .PCD v.7 - Point Cloud Data file format
VERSION .7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 12909
HEIGHT 1
VIEWPOINT 0 0 -2 0 1 0 0
POINTS 12909
DATA ascii
-0.9619 0.2466 0 4210752
-0.9619 0.2487 0 4210752
-0.9625 0.2519 0 4210752
-0.9627 0.2552 0 4210752
-0.963 0.2583 0 4210752
-0.963 0.2614 0 4210752
-0.963 0.2646 0 4210752
-0.963 0.2678 0 4210752
-0.963 0.2709 0 4210752
-0.963 0.2741 0 4210752
-0.963 0.2773 0 4210752
-0.963 0.2805 0 4210752
-0.963 0.2836 0 4210752
-0.963 0.2868 0 4210752
-0.963 0.29 0 4210752
-0.963 0.2932 0 4210752
-0.963 0.2963 0 4210752
-0.963 0.2995 0 4210752

Hope this helps,
I am not sure what is the data format for the color channels, any hint on that might be helpful, also is there any way to convert the las to pcd to obtain a single channel rgb color directly?

Having working with pcd a lot, never heard of ‘separate color channels’. A couple of ideas:

i) your sample pcd output seems to store way too much fields (16). Maybe this is due to your pdal cli conversion step. Remember that acording to documentation:

PCDLoader supports /…/ the following PCD fields:

  • x y z
  • rgb
  • normal_x normal_y normal_z
  • intensity
  • label

ii) The following piece of data will not be very usable:

FIELDS /…/ red green blue
DATA /…/ 19018.00 17219.00 16191.00

Remember that color data is expected to be normalized (0-1 range).

You can obtain clean and normalized pcd output using Cloudcompare. Import your .las file, erase undesired fields/scalarFields and export to pcd, that should give you consistent results with pcd loader.

Good luck :+1:

1 Like

I used cloud compare to convert las to pcd and the color data is retained, indeed the issue is with the PDAL CLI
Thanks for the solution!

2 Likes

Sounds great. It would be ideal if you could mark this as solved for telling others with similar issues that a solution was found. Specially selecting my answer :sweat_smile: thanks!

1 Like