-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotEdgeOverlay.asv
More file actions
44 lines (37 loc) · 1.32 KB
/
plotEdgeOverlay.asv
File metadata and controls
44 lines (37 loc) · 1.32 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function plotEdgeOverlayWithCenters(ptCloud, targetPoints, titleText)
figure
pcshow(ptCloud.Location, ptCloud.Intensity, 'MarkerSize', 20)
hold on
xlim([518036.5 518038.5]); ylim([4972912.5 4972913.5]);
caxis([0 100])
colormap gray
xlabel('X'); ylabel('Y'); zlabel('Z');
title(titleText)
epsilon = 0.02;
minpts = 10;
labels = dbscan(targetPoints(:,1:2), epsilon, minpts);
uniqueLabels = unique(labels);
for k = 1:length(uniqueLabels)
if uniqueLabels(k) == -1
continue
end
clusterPoints = targetPoints(labels == uniqueLabels(k), :);
XY = clusterPoints(:,1:2);
try
k_bnd = boundary(XY(:,1), XY(:,2), 0.9);
edgePts = clusterPoints(k_bnd, 1:3);
% Plot red outline
plot3(edgePts(:,1), edgePts(:,2), edgePts(:,3), 'r-', 'LineWidth', 2);
% Estimate center (2D XY centroid)
centerX = mean(edgePts(:,1));
centerY = mean(edgePts(:,2));
centerZ = mean(edgePts(:,3)); % optional for 3D
% Mark center
scatter3(centerX, centerY, centerZ, 60, 'g', 'filled');
text(centerX, centerY, centerZ + 0.02, sprintf('C%d', k), 'Color', 'w', 'FontSize', 10);
catch
continue
end
end
view(0, 0)
end