This repository has been archived by the owner on May 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
layersCentroids3D.m
57 lines (46 loc) · 1.81 KB
/
layersCentroids3D.m
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
45
46
47
48
49
50
51
52
53
54
55
56
function layersCentroids3D( pathArchMat, initialFrame )
close all;
%Carga las semillas
load(pathArchMat);
%Representar las semillas segun la capa y por tanto, por color.
Color=colorcube(10);
numCentroid=1;
f=figure('Visible', 'on');
for numFrame=initialFrame:size(centroids)
for numLayer=1:size(LayerCentroid, 1)
for numCentroidLayer=1:size(LayerCentroid{numLayer,1}(:, 1),1)
if LayerCentroid{numLayer,1}(numCentroidLayer,1)==numFrame
plot3(LayerCentroid{numLayer,1}(numCentroidLayer,2), LayerCentroid{numLayer,1}(numCentroidLayer, 3), numFrame, '*','MarkerEdgeColor', Color(numLayer,:), 'MarkerFaceColor', Color(numLayer,:));
hold on;
FinalMatrix(numCentroid,1:3)=horzcat(LayerCentroid{numLayer,1}(numCentroidLayer,2), LayerCentroid{numLayer,1}(numCentroidLayer, 3), numFrame);
numCentroid=numCentroid+1;
end
end
end
end
voronoin
%LayerCentroid=cellfun(@(x) x(:,1)*0.1,LayerCentroid,'UniformOutput', false);
% [V,C]=voronoin(FinalMatrix);
X=[LayerCentroid{1,1}*0.9;LayerCentroid{1,1}*1.1];
[V,C]=voronoin(X);
V(1,:)=[];
C=cellfun(@(x) x(x>1)-1,C,'UniformOutput', false);
C1 = C(1:size(LayerCentroid{1, 1}, 1));
for numFaces=1:size(C1,1)
%facesConv{numFaces,1}=convhulln(V(C1{numFaces}, :));
facesAlpha{numFaces,1}=alphaShape(V(C1{numFaces}, :));
k{numFaces,1}=boundary(V(C1{numFaces}, :),0);
%facesBoun{numFaces,1}=V(k{numFaces});
end
figure
% hold on;
% figure('Visible', 'on');
% trisurf(k,V(k{:,1}),V(k(:,2)),V(k(:,3)),'Facecolor','red','FaceAlpha',0.1);
vert=V(C1{1},:);
patch('Faces',k{1},'Vertices', vert, 'FaceColor','b');
% figure
% patch('Faces',facesConv,'Vertices',V, 'FaceColor','b');
figure
%patch('Faces',facesAlpha{1},'Vertices', vert, 'FaceColor','b');
plot(facesAlpha{1});
end