summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/tracking/src/c/fillFeatures.c
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/tracking/src/c/fillFeatures.c')
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/fillFeatures.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/tracking/src/c/fillFeatures.c b/SD-VBS/benchmarks/tracking/src/c/fillFeatures.c
new file mode 100644
index 0000000..42de169
--- /dev/null
+++ b/SD-VBS/benchmarks/tracking/src/c/fillFeatures.c
@@ -0,0 +1,67 @@
1/********************************
2
3Author: Sravanthi Kota Venkata
4********************************/
5
6#include "tracking.h"
7
8/** Find the position and values of the top N_FEA features
9 from the lambda matrix **/
10
11F2D* fillFeatures(F2D* lambda, int N_FEA, int win)
12{
13 int i, j, k, l;
14 int rows = lambda->height;
15 int cols = lambda->width;
16 F2D* features;
17
18 features = fSetArray(3, N_FEA, 0);
19
20 /** init array **/
21 for(i=0; i<N_FEA; i++)
22 {
23 subsref(features, 0, i) = -1.0;
24 subsref(features, 1, i) = -1.0;
25 subsref(features, 2, i) = 0.0;
26 }
27
28
29 /**
30 Find top N_FEA values and store them in
31 features array along with row and col information
32 It should be possible to make this algorithm better
33 if we use a pointer-based data structure,
34 but have not implemented due to MATLAB compatibility
35 **/
36
37 for (i=win; i<rows-win; i++)
38 {
39 for (j=win; j<cols-win; j++)
40 {
41 float currLambdaVal = subsref(lambda,i,j);
42 if (subsref(features, 2, N_FEA-1) > currLambdaVal)
43 continue;
44
45 for (k=0; k<N_FEA; k++)
46 {
47 if (subsref(features, 2, k) < currLambdaVal)
48 {
49 /** shift one slot **/
50 for (l=N_FEA-1; l>k; l--)
51 {
52 subsref(features, 0, l) = subsref(features, 0, l-1);
53 subsref(features, 1, l) = subsref(features, 1, l-1);
54 subsref(features, 2, l) = subsref(features, 2, l-1);
55 }
56
57 subsref(features, 0, k) = j * 1.0;
58 subsref(features, 1, k) = i * 1.0;
59 subsref(features, 2, k) = currLambdaVal;
60 break;
61 }
62 }
63 }
64 }
65
66 return features;
67}