필터 지우기
필터 지우기

How to rotate or align point cloud ?

조회 수: 39 (최근 30일)
Lyhour Chhay
Lyhour Chhay 2021년 12월 25일
댓글: Lyhour Chhay 2021년 12월 27일
Excuse me everyone! I have point cloud as shown in the figure. I want to rotate to the horizontal plane. The rotation point is the middle. How can I do it ? Thank you very much.

채택된 답변

Matt J
Matt J 2021년 12월 25일
편집: Matt J 2021년 12월 26일
Since your point cloud is is not perfectly coplanar, you will need to fit a plane to it in order to determine the necessary rotation. You can do that with planarFit() from this downloadable package:
pfit=planarFit(plyRoi.Location.');
Having done this, you can also use some of the Hidden methods of the pfit object to do the rotation:
XYZ=plyRoi.Location;
x0=mean(XYZ);
R=pfit.vecrot(pfit.normal,[0,0,1]); %compute 3x3 rotation matrix
result=pointCloud((XYZ-x0)*R.'+x0); %rotated point cloud
  댓글 수: 14
Matt J
Matt J 2021년 12월 26일
편집: Matt J 2021년 12월 26일
Here is the code I used, and the results I obtained,
XYZ=plyRoi.Location;
pfit=planarFit(XYZ');
x0=mean(XYZ);
R=pfit.vecrot(pfit.normal,[0,0,1]); %compute 3x3 rotation matrix
result=num2cell((XYZ-x0)*R'+x0,1); %rotated point cloud
[hF,h1]=plot(pfit); hold on
h2=scatter3(result{:},'filled','MarkerFaceColor','g'); hold off
axis(0.07*[-1,1,-1,1,-1,0])
view(-25,3)
legend([h1,hF,h2],'Old Cloud','Plane Fit','New Cloud',...
'location','north')
Lyhour Chhay
Lyhour Chhay 2021년 12월 27일
Dear Image Analyst and Matt J,
I really apprecicate your kindness and thank you very much. Please apology for my late response due to it is night time for me while you were commented. Really big thank to Matt j for your coding, now I can run it and solve it. the problem is about this statement:
  • pfit=planarFit(plyRoi.Location); --> this statement is request big size ram
  • XYZ=plyRoi.Location; pfit=planarFit(XYZ'); --> working !!!! I really suprise that it is worked.
Again, thank you all for helping me to solve this problem. Have nice day and wish you the best for coming new year.
Best Regards,
CHHAY LYHOUR

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

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 12월 25일
You forgot to attach your data, which would have made it easier.
So I'd guess at something like
% Fit a line through the data.
coefficients = polyfit(x, y, 1);
% Then get the mean y
meany = mean(y);
% Get a fitted y
fittedy = polyval(coefficients, x);
% Then subtract the fitted values and add the vertical offset.
rotatedy = y - fittedy + meany;
plot(x, rotatedy, '.', 'MarkerSize', 10);
  댓글 수: 9
Image Analyst
Image Analyst 2021년 12월 25일
Well give him time - it is Christmas Day after all. 🎅
Lyhour Chhay
Lyhour Chhay 2021년 12월 26일
Dear Sir (Image Analyst)
Thank you very much sir for your suggestion and guidance. I am sorry for my late response due to different time zone. Merry Christmas wish you the best. Thank you sir.

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

카테고리

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