# scale a point cloud (enlarge or reduce)

20 ビュー (過去 30 日間)
Alberto Acri 2022 年 11 月 29 日

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 Center および File ExchangePoint Cloud Processing についてさらに検索

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by