I have a point cloud of this object

And I want to measure the distance between the plane where the piece is sitting on and the points marked as red, and as blue. I already have the plane equation, allowing me to remove the points corresponding to the plane and to calculate the distance between it and the points. But I can't figure out how to select the red and blue points, any methods that could help solve this problem?

- If your cloud has high quality normals, you can try to leverage the discontinuities between the sub-parts using
pcl::RegionGrowing with a strict smoothness criteria (If the deviation between points normals is less than the smoothness threshold then they are suggested to be in the same cluster).
- If you know the size of all sub-parts, you can calculate an oriented bounding-box, and then (roughly) cut-out the two round parts.
- If you don't know the size, then after you calculate an oriented bounding-box (and rotate so that x is the long axis - for example), you bin the x values, and calculate for each x, the min/max y values. This should give you a sense of it's shape.
Either way, once you have a sub-part, you can calculate it's center of mass, and then calculate for each point, the distance to the center. This will give you a distribution of radius.
- If you have finer sub-parts (from method #1 above), you can determine which is what by considering the mean and min radius.
- If you have a rough sub-part (from method #2/#3 above), you should segment points as "red"/"blue" based on the radius. You might have to do this iteratively (refining the center of mass each time).