-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvoronoiRegions.m
67 lines (57 loc) · 1.65 KB
/
voronoiRegions.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
57
58
59
60
61
62
63
64
65
66
67
function [ bounded ] = voronoiRegions( v,c,boundAreaMask )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
count=1;
% find unbounded points
for i = 1:length(c)
if any(c{i}==1)
bounded(count).edge=[v(c{i},1),v(c{i},2)];
count=count+1;
end
end
% edges1=regions(boundAreaMask,bounded,1);
% ue1=unique(edges1,'rows')
% edges2=regions(boundAreaMask,bounded,0);
% ue2=unique(edges2,'rows')
% for ii=1:length(bounded)
% fprintf('area %d \n',ii)
% bounded(ii).edge
% end
% disp(inPoint1);
% disp('segments')
% disp(inPoint2);
% find adjacent corner point
% cornerPoint = minCorner( cc,inPoint1,inPoint2 );
end
function [edges]=regions(intersectingPoints,unbounded,flag)
inPoint1=[];inPoint2=[];
for aa=1:length(unbounded)
aaEdge=unbounded(aa).edge;
ind=find(aaEdge==inf,1);
if(ind<size(aaEdge,1))
FstPoint=aaEdge(ind-1,:);
SndPoint=aaEdge(ind+1,:);
else
FstPoint=aaEdge(ind-1,:);
SndPoint=aaEdge(1,:);
end
% find nearest intersect point
taken=[];
if(flag)
ind=emin(intersectingPoints,FstPoint,taken);
else
ind=emax(intersectingPoints,FstPoint,taken);
end
% populate taken
inPoint1=[inPoint1;intersectingPoints(ind,:)];
taken=[taken;ind];
% find nearest intersect point
if(flag)
ind2=emin(intersectingPoints,SndPoint,taken);
else
ind2=emax(intersectingPoints,SndPoint,taken);
end
inPoint2=[inPoint2;intersectingPoints(ind2,:)];
edges=[inPoint1,inPoint2];
end
end