-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexample1.m
More file actions
27 lines (22 loc) · 800 Bytes
/
example1.m
File metadata and controls
27 lines (22 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% Synthetic toy point cloud
N = 10000;
theta = 2*pi*rand(N,1);
phi = acos(2*rand(N,1)-1);
r = 1 + 0.05*randn(N,1); % noisy radius
X = [r.*sin(phi).*cos(theta), ...
r.*sin(phi).*sin(theta), ...
r.*cos(phi)];
% Colour by spatial position (so nearby points have similar colours)
C = 0.5 + 0.5*[X(:,1), X(:,2), X(:,3)];
C = max(min(C,1),0); % clamp to [0,1]
% Fit variational Bayesian Gaussian splats
K = 64; iters = 20;
[M, hist] = vbgs_fit_batch(X, C, K, iters);
% Predict colour for some query points
[c_hat, r] = vbgs_query_color(M, X(1:10,:));
disp(c_hat(1:5,:))
% Visualise components (means)
scatter3(X(:,1), X(:,2), X(:,3), 5, C, 'filled'); hold on;
mu = cat(2,M.spat_post.mu)';
scatter3(mu(:,1), mu(:,2), mu(:,3), 100, 'k', 'filled');
axis equal; title('VBGS synthetic sphere');