# scale a point cloud (enlarge or reduce)

조회 수: 11 (최근 30일)
Alberto Acri 2022년 11월 29일
답변: Jeffrey Clark 2022년 11월 30일
Hi. Is there a method to scale a point cloud (enlarge or reduce)?
I have Rowsx3 coordinates in a .txt file that I turned into a point cloud with the pointCloud command. I want at this point to scale the point cloud so that it has the same size as another point cloud (I have the same object, but different point cloud) possibly using a parameter. Is this possible?

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

### 답변 (1개)

Jeffrey Clark 2022년 11월 30일
@Alberto Acri, I don't have the toolbox you do but you should be able to expand Rowsx3 similar to this (red are added):
% Create an example Rowsx3
[x,y,z] = sphere(60);
i = randperm(length(x(:)));
Rowsx3 = [x(i)' y(i)' z(i)'];
% Find nearest neighbors
d2d = (Rowsx3(:,1)-Rowsx3(:,1)').^2+(Rowsx3(:,2)-Rowsx3(:,2)').^2+(Rowsx3(:,3)-Rowsx3(:,3)').^2;
d2d(d2d(:)==0) = nan;
[d2dm,d2di] = min(d2d);
% If want 75x75 = 5625 instead of 3721 (61x61)
k = (75^2-length(Rowsx3));
% Choose mean of random nearest neighbors for cloud growth
ei = randperm(length(Rowsx3),k);
Rowsx3e(:,3) = mean([Rowsx3(d2di(ei),3) Rowsx3(ei,3)],2);
Rowsx3e(:,2) = mean([Rowsx3(d2di(ei),2) Rowsx3(ei,2)],2);
Rowsx3e(:,1) = mean([Rowsx3(d2di(ei),1) Rowsx3(ei,1)],2);
% Plot original as blue and extension as red (red are added)
figure
plot3(Rowsx3(:,1),Rowsx3(:,2),Rowsx3(:,3),'b.',Rowsx3e(:,1),Rowsx3e(:,2),Rowsx3e(:,3),'r.')
axis square; axis equal
As for reducing Rowsx3 just removing some of the nearest neighbors should work as well (red are removed):
% . . .
% If want 50x50 = 2500 instead of 3721 (61x61)
k = (50^2-length(Rowsx3));
% Choose random nearest neighbors for cloud reduction
ei = randperm(length(Rowsx3),-k);
Rowsx3r = Rowsx3;
Rowsx3r(ei,:) = [];
% Plot original as red and remaining as blue (red are removed)
figure
plot3(Rowsx3(:,1),Rowsx3(:,2),Rowsx3(:,3),'r.',Rowsx3r(:,1),Rowsx3r(:,2),Rowsx3r(:,3),'b.')
axis square; axis equal

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

### 카테고리

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

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by