summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/stitch/src/c
diff options
context:
space:
mode:
authorLeo Chan <leochanj@live.unc.edu>2020-10-22 01:53:21 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-22 01:56:35 -0400
commitd17b33131c14864bd1eae275f49a3f148e21cf29 (patch)
tree0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/benchmarks/stitch/src/c
parent601ed25a4c5b66cb75315832c15613a727db2c26 (diff)
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to: - Use libextra to loop as realtime jobs - Preallocate memory before starting their main computation - Accept input via stdin instead of via argc Does not include the SD-VBS matlab code. Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/benchmarks/stitch/src/c')
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/dist2.c76
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/extractFeatures.c181
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/getANMS.c145
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/harris.c141
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/matchFeatures.c55
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/maxWindow.c51
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/script_stitch.c65
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/stitch.h22
-rw-r--r--SD-VBS/benchmarks/stitch/src/c/supress.c29
9 files changed, 765 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/stitch/src/c/dist2.c b/SD-VBS/benchmarks/stitch/src/c/dist2.c
new file mode 100644
index 0000000..d76fcb2
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/dist2.c
@@ -0,0 +1,76 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "stitch.h"
6
7F2D* dist2(I2D* x, F2D* c)
8{
9 int ndata, dimx, ncentres, dimc, i, j, k;
10 F2D *n2, *t1, *t2;
11 float temp;
12 F2D *s1, *s2, *ctrans;
13 F2D *mult1, *mult2, *mult3;
14
15 ndata = x->height;
16 dimx = x->width;
17
18 ncentres = c->height;
19 dimc = c->width;
20
21 if(dimx != dimc)
22 return NULL;
23
24 s1 = fSetArray(ncentres, 1, 1);
25 s2 = fSetArray(ndata, 1, 1);
26 t1 = fMallocHandle(1, x->height);
27
28 for(j=0; j<t1->width; j++)
29 {
30 temp = 0;
31 for(i=0; i<t1->height; i++)
32 {
33 temp += subsref(x,j,i) * subsref(x,j,i);
34 }
35
36 asubsref(t1,j) = temp;
37 }
38
39 mult1 = fMtimes(s1, t1);
40 t2 = fMallocHandle(1, c->height);
41
42 for(j=0; j<t2->width; j++)
43 {
44 temp = 0;
45 for(i=0; i<t2->height; i++)
46 {
47 temp += subsref(c,j,i) * subsref(c,j,i);
48 }
49
50 asubsref(t2,j) = temp;
51 }
52
53 mult2 = fMtimes(s2, t2);
54 ctrans = fTranspose(c);
55 mult3 = ifMtimes(x, ctrans);
56
57 for(i=0; i<(mult3->height * mult3->width); i++)
58 asubsref(mult3,i) = asubsref(mult3,i) * 2;
59
60 free(t1);
61 free(t2);
62 free(s1);
63 free(s2);
64 free(ctrans);
65
66 n2 = fMallocHandle(ndata, ncentres);
67 for(i=0; i<(ndata*ncentres); i++)
68 asubsref(n2,i) = asubsref(mult1,i) + asubsref(mult2,i) - asubsref(mult3,i);
69
70 free(mult1);
71 free(mult2);
72 free(mult3);
73
74 return n2;
75
76}
diff --git a/SD-VBS/benchmarks/stitch/src/c/extractFeatures.c b/SD-VBS/benchmarks/stitch/src/c/extractFeatures.c
new file mode 100644
index 0000000..ea574e4
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/extractFeatures.c
@@ -0,0 +1,181 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "stitch.h"
6#include <math.h>
7
8#define min(a,b) (a<b)?a:b
9
10F2D* extractFeatures(I2D* I, F2D* x, F2D* y)
11{
12 int n, i, j, k;
13 F2D* I1;
14 F2D *Iconv;
15 F2D *Isub;
16 int nr, nc;
17 F2D *w, *wt, *vecF;
18 I2D *Xsub, *Ysub;
19 float temp, mean, std;
20 int m;
21 F2D *g1, *g;
22
23 g1 = fSetArray(5,5,0);
24
25 asubsref(g1,0) = 1;
26 asubsref(g1,1) = 4;
27 asubsref(g1,2) = 6;
28 asubsref(g1,3) = 4;
29 asubsref(g1,4) = 1;
30
31 asubsref(g1,5) = 4;
32 asubsref(g1,6) = 16;
33 asubsref(g1,7) = 24;
34 asubsref(g1,8) = 16;
35 asubsref(g1,9) = 4;
36
37 asubsref(g1,10) = 6;
38 asubsref(g1,11) = 24;
39 asubsref(g1,12) = 36;
40 asubsref(g1,13) = 24;
41 asubsref(g1,14) = 6;
42
43 asubsref(g1,15) = 4;
44 asubsref(g1,16) = 16;
45 asubsref(g1,17) = 24;
46 asubsref(g1,18) = 16;
47 asubsref(g1,19) = 4;
48
49 asubsref(g1,20) = 1;
50 asubsref(g1,21) = 4;
51 asubsref(g1,22) = 6;
52 asubsref(g1,23) = 4;
53 asubsref(g1,24) = 1;
54
55 g = fDivide(g1, 256);
56 n = x->height;
57
58 vecF = fMallocHandle(n, 64);
59 I1 = fiDeepCopy(I);
60
61 Iconv = ffConv2(I1, g);
62 fFreeHandle(I1);
63 I1 = ffConv2(Iconv, g);
64 fFreeHandle(Iconv);
65 Iconv = fDeepCopy(I1);
66
67 {
68 int i = (Iconv->height/5);
69 int j = (Iconv->width/5);
70 Isub = fMallocHandle(i, j);
71 }
72
73 for(i=0, m=0; m<Isub->height; i+=5, m++)
74 {
75 for(j=0, k=0; k<Isub->width; j+=5, k++)
76 {
77 subsref(Isub,m,k) = subsref(Iconv,i,j);
78 }
79 }
80
81 fFreeHandle(Iconv);
82 fFreeHandle(g1);
83 fFreeHandle(g);
84 fFreeHandle(I1);
85
86 nr = Isub->height;
87 nc = Isub->width;
88
89 Xsub = iMallocHandle(x->height, x->width);
90 Ysub = iMallocHandle(y->height, y->width);
91
92// printf("Sizes = %d\t%d\t%d\t%d\n", Isub->height, Isub->width, x->height, x->width);
93
94 for(i=0; i<(x->height*x->width); i++)
95 {
96 asubsref(Xsub,i) = min( ( asubsref(x,i) /5), nc-4 );
97 asubsref(Ysub,i) = min( ( asubsref(y,i) /5), nr-4 );
98 }
99
100 {
101 int maxX, maxY;
102 maxX = Xsub->height>Xsub->width?Xsub->height:Xsub->width;
103 maxY = Ysub->height>Ysub->width?Ysub->height:Ysub->width;
104 if(maxX < 6 || maxY < 10)
105 {
106 fFreeHandle(vecF);
107 vecF = fSetArray(n,2,0);
108 for(i=0; i<(x->height); i++)
109 {
110 subsref(vecF, i, 0) = asubsref(Xsub,i)*1.0;
111 subsref(vecF, i, 1) = asubsref(Ysub,i)*1.0;
112 }
113
114 fFreeHandle(Isub);
115 iFreeHandle(Xsub);
116 iFreeHandle(Ysub);
117 return vecF;
118 }
119 }
120
121 {
122 int newSize = 4;
123 if(I->height > 32 && I->width >32)
124 newSize = 64;
125 fFreeHandle(vecF);
126 vecF = fMallocHandle(n, newSize);
127 }
128
129// printf("Size of Isub = %d\t%d\n", Isub->height, Isub->width);
130 for(i=0; i<n; i++)
131 {
132
133 if( asubsref(Ysub,i) < 3)
134 asubsref(Ysub,i) = 3;
135 if( asubsref(Xsub,i) < 3)
136 asubsref(Xsub,i) = 3;
137
138 if( asubsref(Ysub,i) >= (Isub->height-4))
139 asubsref(Ysub,i) = Isub->height-5;
140 if( asubsref(Xsub,i) >= (Isub->width-4))
141 asubsref(Xsub,i) = Isub->width-5;
142
143 m = 0;
144 temp = 0;
145// printf("SUBS %d\t%d\n", asubsref(Ysub,i), asubsref(Xsub,i));
146
147 for(k= asubsref(Xsub,i)-3; k<=( asubsref(Xsub,i)+4); k++)
148 {
149 for(j= asubsref(Ysub,i)-3; j<=( asubsref(Ysub,i)+4); j++)
150 {
151// printf("%d\t%d\n", j, k);
152 subsref(vecF,i,m) = subsref(Isub,j,k);
153 temp += subsref(vecF,i,m);
154 m++;
155 }
156 }
157 mean = temp/64.0;
158
159 std = 0;
160 for(j=0; j<64; j++)
161 {
162 subsref(vecF,i,j) = subsref(vecF,i,j) - mean;
163 std += subsref(vecF,i,j) * subsref(vecF,i,j);
164 }
165
166 std = std/64;
167 std = sqrt(std);
168 for(j=0; j<64; j++)
169 {
170 subsref(vecF,i,j) = subsref(vecF,i,j)/std;
171 }
172 }
173
174 iFreeHandle(Xsub);
175 fFreeHandle(Isub);
176 iFreeHandle(Ysub);
177 return vecF;
178}
179
180
181
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}
diff --git a/SD-VBS/benchmarks/stitch/src/c/harris.c b/SD-VBS/benchmarks/stitch/src/c/harris.c
new file mode 100644
index 0000000..a24c2b4
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/harris.c
@@ -0,0 +1,141 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "stitch.h"
6
7F2D* harris(I2D* im)
8{
9 F2D *img1;
10 F2D *g1, *g2, *g;
11 F2D *Ix, *Iy;
12 F2D *Ix2, *Iy2, *IxIy;
13 F2D *v, *R, *Rmax, *Rnm;
14 float eps;
15 F2D *sobel, *sob, *temp, *temp1;
16 I2D *win, *x, *y;
17 int i;
18
19 g1 = fSetArray(5,5,0);
20 g2 = fSetArray(3,3,0);
21
22 asubsref(g1,0) = 1;
23 asubsref(g1,1) = 4;
24 asubsref(g1,2) = 6;
25 asubsref(g1,3) = 4;
26 asubsref(g1,4) = 1;
27
28 asubsref(g1,5) = 4;
29 asubsref(g1,6) = 16;
30 asubsref(g1,7) = 24;
31 asubsref(g1,8) = 16;
32 asubsref(g1,9) = 4;
33
34 asubsref(g1,10) = 6;
35 asubsref(g1,11) = 24;
36 asubsref(g1,12) = 36;
37 asubsref(g1,13) = 24;
38 asubsref(g1,14) = 6;
39
40 asubsref(g1,15) = 4;
41 asubsref(g1,16) = 16;
42 asubsref(g1,17) = 24;
43 asubsref(g1,18) = 16;
44 asubsref(g1,19) = 4;
45
46 asubsref(g1,20) = 1;
47 asubsref(g1,21) = 4;
48 asubsref(g1,22) = 6;
49 asubsref(g1,23) = 4;
50 asubsref(g1,24) = 1;
51
52 asubsref(g2,0) = 1;
53 asubsref(g2,1) = 2;
54 asubsref(g2,2) = 1;
55
56 asubsref(g2,3) = 2;
57 asubsref(g2,4) = 4;
58 asubsref(g2,5) = 2;
59
60 asubsref(g2,6) = 1;
61 asubsref(g2,7) = 2;
62 asubsref(g2,8) = 1;
63
64 g = fDivide(g1, 256);
65 sob = fMallocHandle(1,3);
66 asubsref(sob,0) = -0.5;
67 asubsref(sob,1) = 0;
68 asubsref(sob,2) = 0.5;
69
70 {
71 F2D* imf;
72 imf = fiDeepCopy(im);
73 img1 = ffConv2(imf, g);
74 fFreeHandle(imf);
75 }
76
77 Ix = ffConv2(img1, sob);
78 fFreeHandle(sob);
79 sob = fMallocHandle(3,1);
80 asubsref(sob,0) = -0.5;
81 asubsref(sob,1) = 0;
82 asubsref(sob,2) = 0.5;
83 Iy = ffConv2(img1, sob);
84
85 fFreeHandle(g);
86 g = fDivide(g2, 16);
87 eps = 2.2204e-16;
88 sobel = fTimes(Ix, Ix);
89 Ix2 = ffConv2(sobel, g);
90 fFreeHandle(sobel);
91
92 sobel = fTimes(Iy, Iy);
93 Iy2 = ffConv2(sobel, g);
94 fFreeHandle(sobel);
95
96 sobel = fTimes(Ix, Iy);
97 IxIy = ffConv2(sobel, g);
98 fFreeHandle(sobel);
99
100 temp = fTimes(Ix2, Iy2);
101 temp1 = fTimes(IxIy, IxIy);
102 sobel = fMinus(temp, temp1);
103
104 fFreeHandle(temp);
105 temp = fPlus(Ix2, Iy2);
106
107 for(i=0; i<(temp->height*temp->width); i++)
108 asubsref(temp,i) += eps;
109
110 R = ffDivide(sobel, temp);
111
112 win = iSetArray(1,2,3);
113 Rmax = maxWindow(R, win);
114 Rnm = supress(R, Rmax);
115
116 v = fFind3(Rnm);
117
118 iFreeHandle(win);
119 fFreeHandle(Rmax);
120 fFreeHandle(Rnm);
121 fFreeHandle(R);
122
123 fFreeHandle(img1);
124 fFreeHandle(g1);
125 fFreeHandle(g2);
126 fFreeHandle(g);
127 fFreeHandle(Ix);
128 fFreeHandle(Iy);
129 fFreeHandle(Ix2);
130 fFreeHandle(Iy2);
131 fFreeHandle(IxIy);
132 fFreeHandle(sobel);
133 fFreeHandle(sob);
134 fFreeHandle(temp);
135 fFreeHandle(temp1);
136// iFreeHandle(x);
137// iFreeHandle(y);
138
139 return v;
140}
141
diff --git a/SD-VBS/benchmarks/stitch/src/c/matchFeatures.c b/SD-VBS/benchmarks/stitch/src/c/matchFeatures.c
new file mode 100644
index 0000000..5450eb9
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/matchFeatures.c
@@ -0,0 +1,55 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "stitch.h"
6
7I2D* matchFeatures(F2D* vecF1, F2D* vecF2)
8{
9 int m, n, n1, n2, n1c, n2c, i, j;
10 I2D *id, *retMatch, *t;
11 F2D *val, *temp;
12 int rows, cols;
13
14 n1 = vecF1->height;
15 n1c = vecF1->width;
16 n2 = vecF2->height;
17 n2c = vecF2->width;
18
19 retMatch = iMallocHandle(1, 2);
20
21 for(i=0; i<n1; i++)
22 {
23 id = iMallocHandle(1, n2);
24 t = iMallocHandle(1, n1c);
25
26 for(j=0; j<n1c; j++)
27 asubsref(t,j) = subsref(vecF1,i,j);
28
29 temp = dist2(t, vecF2);
30 val = fSort(temp,1);
31 id = fSortIndices(temp,1);
32
33 free(temp);
34 free(t);
35
36 if( asubsref(val,1) != 0 & (( asubsref(val,0) / asubsref(val,1) ) < 0.65))
37 {
38 t = retMatch;
39 rows = t->height + 1;
40 cols = t->width;
41 retMatch = iMallocHandle(rows, cols);
42 n = 0;
43
44 for(m=0; m<(t->height*t->width); m++)
45 {
46 asubsref(retMatch,n++) = asubsref(t,m);
47 }
48
49 asubsref(retMatch,n++) = i;
50 asubsref(retMatch,n) = asubsref(id,0);
51 }
52 }
53
54 return retMatch;
55}
diff --git a/SD-VBS/benchmarks/stitch/src/c/maxWindow.c b/SD-VBS/benchmarks/stitch/src/c/maxWindow.c
new file mode 100644
index 0000000..07f8dc9
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/maxWindow.c
@@ -0,0 +1,51 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "stitch.h"
6
7F2D* maxWindow(F2D* im, I2D* window)
8{
9 int exR, exC, rows, cols, tr, tc, i, j, k;
10 F2D *out, *temp;
11 float t;
12 int m;
13
14 exR = asubsref(window,0)/2;
15 exC = asubsref(window,1)/2;
16
17 rows = im->height;
18 cols = im->width;
19
20 tr = rows+exR-1;
21 tc = cols+exC-1;
22 temp = fDeepCopy(im);
23 out = fMallocHandle(rows, cols);
24
25 for(i=0; i<rows; i++)
26 {
27 for(j=0; j<cols; j++)
28 {
29 t = 0;
30 for(k=-exR; k<=exR; k++)
31 {
32 for(m=-exC; m<=exC; m++)
33 {
34 if( (i+k) < 0 || (i+k) >= rows || (j+m) < 0 || (j+m) >= cols)
35 continue;
36 if( subsref(temp,(i+k),(j+m)) > t)
37 t = subsref(temp,(i+k),(j+m));
38 }
39 }
40 subsref(out,i,j) = t;
41 }
42 }
43
44 fFreeHandle(temp);
45 return out;
46}
47
48
49
50
51
diff --git a/SD-VBS/benchmarks/stitch/src/c/script_stitch.c b/SD-VBS/benchmarks/stitch/src/c/script_stitch.c
new file mode 100644
index 0000000..00c9a93
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/script_stitch.c
@@ -0,0 +1,65 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "stitch.h"
6#include <malloc.h>
7#include "extra.h"
8#define STITCH_MEM 1<<30
9int main(int argc, char* argv[])
10{
11 SET_UP
12 mallopt(M_TOP_PAD, STITCH_MEM);
13 mallopt(M_MMAP_MAX, 0);
14 int rows, cols;
15 F2D *x, *y, *v, *interestPnts, *Fcur, *int1, *int2;
16 I2D *Icur;
17 int i, j;
18 char im1[100], im2[100];
19
20
21 printf("Input image: ");
22 scanf("%s", im1);
23 Icur = readImage(im1);
24 rows = Icur->height;
25 cols = Icur->width;
26
27 printf("start\n");
28 for_each_job{
29 v = harris(Icur);
30 interestPnts = getANMS(v, 24);
31 int1 = fMallocHandle(interestPnts->height, 1);
32 int2 = fSetArray(interestPnts->height, 1, 0);
33 for(i=0; i<int1->height; i++)
34 {
35 asubsref(int1,i) = subsref(interestPnts,i,0);
36 asubsref(int2,i) = subsref(interestPnts,i,1);
37 }
38
39 Fcur = extractFeatures(Icur, int1, int2);
40 }
41 printf("end..\n");
42
43
44#ifdef CHECK
45 /** Self checking - use expected.txt from data directory **/
46 {
47 int ret=0;
48 float tol = 0.02;
49#ifdef GENERATE_OUTPUT
50 fWriteMatrix(Fcur, argv[1]);
51#endif
52 ret = fSelfCheck(Fcur, "expected_C.txt", tol);
53 if (ret == -1)
54 printf("Error in Stitch\n");
55 }
56#endif
57 iFreeHandle(Icur);
58 fFreeHandle(v);
59 fFreeHandle(interestPnts);
60 fFreeHandle(int1);
61 fFreeHandle(int2);
62 fFreeHandle(Fcur);
63 WRITE_TO_FILE
64 return 0;
65}
diff --git a/SD-VBS/benchmarks/stitch/src/c/stitch.h b/SD-VBS/benchmarks/stitch/src/c/stitch.h
new file mode 100644
index 0000000..e2202fc
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/stitch.h
@@ -0,0 +1,22 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#ifndef _SCRIPT_STITCH_
6#define _SCRIPT_STITCH_
7
8#include "sdvbs_common.h"
9
10F2D* dist2(I2D* x, F2D* c);
11F2D* extractFeatures(I2D* I, F2D* x, F2D* y);
12F2D* getANMS (F2D *points, int r);
13F2D* harris(I2D* im);
14I2D* matchFeatures(F2D* vecF1, F2D* vecF2);
15F2D* maxWindow(F2D* im, I2D* window);
16F2D* supress(F2D* im, F2D* im1);
17int script_stitch();
18
19#endif
20
21
22
diff --git a/SD-VBS/benchmarks/stitch/src/c/supress.c b/SD-VBS/benchmarks/stitch/src/c/supress.c
new file mode 100644
index 0000000..6fbdb6c
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/c/supress.c
@@ -0,0 +1,29 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "stitch.h"
6
7F2D* supress(F2D* im, F2D* im1)
8{
9 int rows, cols, i, j;
10 F2D *out;
11
12 rows = im->height;
13 cols = im->width;
14
15 out = fSetArray(rows, cols, 0);
16
17 for(i=0; i<rows; i++)
18 {
19 for(j=0; j<cols; j++)
20 {
21 if( subsref(im,i,j) == subsref(im1,i,j))
22 subsref(out,i,j) = subsref(im,i,j);
23 }
24 }
25 return out;
26}
27
28
29