0

I have a point cloud with XYZRGB data which was derived from images. Is there any way I can filter the point cloud based on colour data? This is possible in images maybe using OpenCV or some other libraries. I am looking to extract points from the point cloud based on RGB data in python.

Eg: I want to extract white color point from the point cloud.

I looked at open source tool Cloud compare and there is an option to extract points based on color. I want to implement the same but I am lack of procedure/steps to achieve.

1 Answer 1

1

With Python I would load the point cloud (LAS/LAZ) file to numpy array using laspy or pylas, where every point gets stored as a row in numpy array. Once this is done you can use np.where to filter it by R, G and B values. Assuming that your point cloud headers for RGB are red, green and blue. It will look something like this.

import laspy as lp
import numpy as np

point_cloud = lp.read("cube.las")
filterd_pc = np.where((point_cloud.red == 255) & (point_cloud.green == 255) & (point_cloud.blue == 255))

print(filterd_pc)

With CloudCompare you will have to add colors as scalar field first. So once your point cloud is loaded go to Menu->Edit->Colors->Convert to Scalar field

Once you do this select the active scalar field by going to properties tab and select either if R,G,B.

enter image description here

Once done go to Menu->Edit->Scalar fields->Filter by Value . This will allow you to filter based on selected scalar field and its value range.

So for filtering white colors R,G,B should be 255,255,255 respectively. So if the R is selected in scalar field you will have to put a range of 255 to 255. Or you can also put a slightly broader range for different shades of white like 250-255. You can export the point cloud filtered by R values or use split option to split the original point clould and add the filtered points as a separate point cloud in your viewport. You can further filter the R filtered point cloud in similar way with similar range for G followed by a similar filter for B. Remember the R,G,B values should be within 250-255 to cover different ranges of white.

enter image description here

1
  • Thanks @Abhilshit. Yes, I know this but I want to implement the functionality the we are doing in cloud compare in python.
    – sarada
    Jun 3, 2022 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.