summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/stitch/src/c/getANMS.c
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/stitch/src/c/getANMS.c
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/stitch/src/c/getANMS.c')
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/getANMS.c145
1 files changed, 145 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/stitch/src/c/getANMS.c b/SD-VBS/benchmarks/stitch/src/c/getANMS.c
new file mode 100644
index 0000000..fa03a85
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/getANMS.c
@@ -0,0 +1,145 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "stitch.h"
6
7F2D* getANMS (F2D *points, int r)
8{
9 unsigned int MAX_LIMIT = 10000000;
10 F2D *suppressR;
11 float C_ROBUST = 0.9;
12 F2D *srtdPnts;
13 int n, k;
14 I2D *srtdVIdx, *supId;
15 float r_sq, t, t1;
16 F2D *tempF, *srtdV, *interestPnts;
17 int i, j, validCount=0, cnt, end;
18 F2D *v;
19 int iter, rows, cols;
20 F2D* temp;
21 int supIdPtr = 0;
22
23 v = fMallocHandle(points->height, 1);
24 for(i=0; i<v->height; i++)
25 asubsref(v,i) = subsref(points,i,2);
26
27 r_sq = r * r * 1.0;
28 n = v->height;
29
30 srtdVIdx = fSortIndices (v, 1);
31 srtdPnts = fMallocHandle (srtdVIdx->height, points->width);
32
33 for (i = 0; i < srtdVIdx->height; i++)
34 for(j=0; j<points->width; j++)
35 subsref(srtdPnts,i,j) = subsref(points, asubsref(srtdVIdx,i), j);
36
37 temp = fSetArray (1, 3, 0);
38 suppressR = fSetArray(n, 1, MAX_LIMIT);
39
40 validCount = 0;
41 iter = 0;
42 for (i = 0; i < suppressR->height; i++)
43 {
44 if ( asubsref(suppressR,i) > r_sq)
45 {
46 validCount++;
47 }
48 }
49
50 k = 0;
51 supId = iMallocHandle(validCount, 1);
52 for (i = 0; i < (suppressR->height*suppressR->width); i++)
53 {
54 if ( asubsref(suppressR,i) > r_sq)
55 {
56 asubsref(supId,k++) = i;
57 }
58 }
59
60 while (validCount > 0)
61 {
62 F2D *tempp, *temps;
63 asubsref(temp,0) = subsref(srtdPnts, asubsref(supId,0), 0);
64 asubsref(temp,1) = subsref(srtdPnts, asubsref(supId,0), 1);
65 asubsref(temp,2) = subsref(srtdPnts, asubsref(supId,0), 2);
66
67 if(iter == 0)
68 interestPnts = fDeepCopy(temp);
69 else
70 {
71 tempp = fDeepCopy(interestPnts);
72 fFreeHandle(interestPnts);
73 interestPnts = ffVertcat(tempp, temp);
74 fFreeHandle(tempp);
75 }
76 iter++;
77
78 tempp = fDeepCopy(srtdPnts);
79 temps = fDeepCopy(suppressR);
80
81 fFreeHandle(srtdPnts);
82 fFreeHandle(suppressR);
83
84 srtdPnts = fMallocHandle(supId->height-1, 3);
85 suppressR = fMallocHandle(supId->height-1, 1);
86
87 k=0;
88 for(i=1; i<supId->height; i++)
89 {
90 subsref(srtdPnts,k,0) = subsref(tempp, asubsref(supId,i) ,0);
91 subsref(srtdPnts,k,1) = subsref(tempp, asubsref(supId,i) ,1);
92 subsref(srtdPnts,k,2) = subsref(tempp, asubsref(supId,i) ,2);
93 subsref(suppressR,k,0) = subsref(temps, asubsref(supId,i) ,0);
94 k++;
95 }
96
97 fFreeHandle(tempp);
98 fFreeHandle(temps);
99 rows = interestPnts->height-1;
100 cols = interestPnts->width;
101 for (i = 0; i < srtdPnts->height; i++)
102 {
103 t = 0;
104 t1 = 0;
105
106 if ((C_ROBUST * subsref(interestPnts,rows,2)) >= subsref(srtdPnts, i,2))
107 {
108 t = subsref(srtdPnts, i,0) - subsref(interestPnts,rows,0);
109 t1 = subsref(srtdPnts, i,1) - subsref(interestPnts,rows,1);
110 t = t * t + t1 * t1;
111 t1 = 0;
112 }
113
114 if ((C_ROBUST * subsref(interestPnts,rows,2)) < subsref(srtdPnts, i,2))
115 t1 = 1 * MAX_LIMIT;
116
117 if ( asubsref(suppressR, i) > (t + t1))
118 {
119 asubsref(suppressR, i) = t + t1;
120 }
121 }
122
123 validCount=0;
124 for (i = 0; i < suppressR->height; i++)
125 if ( asubsref(suppressR,i) > r_sq)
126 validCount++;
127
128 k = 0;
129 iFreeHandle(supId);
130 supId = iMallocHandle(validCount, 1);
131
132 for (i = 0; i < suppressR->height*suppressR->width; i++)
133 if ( asubsref(suppressR,i) > r_sq)
134 asubsref(supId,k++) = i;
135 }
136
137 iFreeHandle(supId);
138 iFreeHandle(srtdVIdx);
139 fFreeHandle(srtdPnts);
140 fFreeHandle(temp);
141 fFreeHandle(suppressR);
142 fFreeHandle(v);
143
144 return interestPnts;
145}