diff options
| author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
| commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
| tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/benchmarks/stitch/src | |
| parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (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')
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/dist2.c | 76 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/extractFeatures.c | 181 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/getANMS.c | 145 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/harris.c | 141 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/matchFeatures.c | 55 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/maxWindow.c | 51 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/script_stitch.c | 65 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/stitch.h | 22 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/supress.c | 29 |
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 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include "stitch.h" | ||
| 6 | |||
| 7 | F2D* 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 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include "stitch.h" | ||
| 6 | #include <math.h> | ||
| 7 | |||
| 8 | #define min(a,b) (a<b)?a:b | ||
| 9 | |||
| 10 | F2D* 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 | { | ||
