remove point cloud tilt by plane fit

조회 수: 30 (최근 30일)
Istvan
Istvan 2018년 4월 30일
댓글: Brian 2019년 8월 2일
Hello,
I have a point cloud created from vectors as PCdata = pointCloud([X;Y;Z]'); This represents data from a single plane, with an obvious tilt (2D slope) on it, which I would like to get rid of, so I end up with a point cloud on a horizontal plane.
I managed to fit a plane by:
[model1,inlierIndices,outlierIndices] = pcfitplane(PCdata,100);
...but can anyone tell me how to generate the new point cloud, by either: - subtracting the fitted plane from the original PC = new PC that is at a height around 0 and horizontal ? - subtracting the fitted plane's 2D slope (along x and y) = new PC that is horizontal (but has same mean Z) ?
Any other method you can suggest would also be great, I thought plane fitting would be the obvious way.
Thank you!
  댓글 수: 1
Moazza
Moazza 2018년 6월 6일
There is an example in MATLAB, which tell how to subtract the fitted planefrom the original PC and then you get the remaining PC. Please check DetectMultiplePlanesFromPointCloudExample in Matlab R2017a

댓글을 달려면 로그인하십시오.

답변 (2개)

Ben Drebing
Ben Drebing 2018년 5월 4일
편집: Ben Drebing 2018년 5월 4일
I think the fastest way to do this might be to use "pctransform" to rotate your pointcloud. Check out this example:
The only tough part will be defining your rotation matrix (A in the example) and the missing piece of the puzzle is knowing what angles to use to create the matrix. Luckily, the "model1" variable from your plane fit contains a normal vector. This vector basically points "up" in relation to your plane. If you find the angles between this vector and the vector [0,0,1], this will give you the angles needed to rotate the plane until its normal vector is pointing straight up. I thought this link has a pretty good explanation:

Dimitrios Panagiotidis
Dimitrios Panagiotidis 2019년 4월 2일
Well, I would agree with what Ben said, regarding the trasnformation of your point cloud, however a way that might work is to rotate your point cloud using the CloudCompare software (it is a software particlualrly designed for point clouds processing) or at least you can use it to extract in .txt your tranformation matrix and continue with the rest in Matlab. You can rotate the point cloud there relatively easy, it has many options and a GUI where you can directly see any applied transformation on it: If you wish to do that exclusively in Matlab then consider this example:
theta = pi/2
Around X-axis:
X = x;
Y = y*cos(theta) - z*sin(theta);
Z = y*sin(theta) + z*cos(theta);
Around Y-axis:
X = x*cos(theta) + z*sin(theta);
Y = y;
Z = z*cos(theta) - x*sin(theta);
Around Z-axis:
X = x*cos(theta) - y*sin(theta);
Y = x*sin(theta) + y*cos(theta);
Z = z;
it wont be an easy task because you need to know the angle for your rotation and also in which axis to apply it :-) that might get lot of time and effort :-) good luck
  댓글 수: 1
Brian
Brian 2019년 8월 2일
I have a similar task and am trying to use the model.normal output information from using the pcfitplane command that gives the normal vector to the best fit plane of the point cloud. I've calculated the angles that the normal makes with the x,y,z axis' yet am not getting the point cloud to rotate to the horizontal orientation. I've tried using the pctransform as well as making matrices to rotate in x, y, z.. The link that I saw before had different matrices than above though. I will try these and see.
Brian Charles

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by