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/c/harris.c | |
| 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/c/harris.c')
| -rw-r--r-- | SD-VBS/benchmarks/stitch/src/c/harris.c | 141 |
1 files changed, 141 insertions, 0 deletions
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 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include "stitch.h" | ||
| 6 | |||
| 7 | F2D* 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 | |||
