-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_g_feat.m
54 lines (38 loc) · 1.25 KB
/
get_g_feat.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
function [G_feat, G_names, G_poly] = get_g_feat(coord_order,polygons)
% function extract area from the specified polygons using keypoints
triangles = polygons.Triangles;
quads = polygons.Quads;
Tr_name = {};
Qd_name = {};
Area_tr = [];
Area_qd = [];
Tr_polygon = {};
Qd_polygon = {};
for ix = 1:30
tr = triangles(ix,:);
tr_name = strjoin({num2str(tr(1)),num2str(tr(2)),num2str(tr(3))},'-');
Tr_name{ix} = tr_name;
coords_tr = coord_order(tr,:);
tr_polygon = polyshape(coords_tr(:,1),coords_tr(:,2));
area_tr = area(tr_polygon);
Area_tr = [Area_tr, area_tr];
Tr_polygon{ix} = tr_polygon;
end
for ix = 1:20
qd = quads(ix,:);
qd_name = strjoin({num2str(qd(1)),num2str(qd(2)),num2str(qd(3)),num2str(qd(4))},'-');
Qd_name{ix} = qd_name;
coords_quad = coord_order(qd,:);
qd_polygon = polyshape(coords_quad(:,1), coords_quad(:,2));
area_qd = area(qd_polygon);
Area_qd = [Area_qd, area_qd];
Qd_polygon{ix} = qd_polygon;
end
% names
g_names_tr = strcat('G(',Tr_name,')');
g_names_qd = strcat('G(',Qd_name,')');
G_names = [g_names_tr,g_names_qd];
% values
G_feat = [Area_tr, Area_qd];
% polygons
G_poly = [Tr_polygon,Qd_polygon];