summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c')
-rw-r--r--SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c b/SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c
new file mode 100644
index 0000000..0ef1862
--- /dev/null
+++ b/SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c
@@ -0,0 +1,78 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "tracking.h"
6
7/** Computes lambda matrix, strength at each pixel
8
9 det = determinant( [ IverticalEdgeSq IhorzVertEdge; IhorzVertEdge IhorizontalEdgeSq] ) ;
10 tr = IverticalEdgeSq + IhorizontalEdgeSq;
11 lamdba = det/tr;
12
13 Lambda is the measure of the strength of pixel
14 neighborhood. By strength we mean the amount of
15 edge information it has, which translates to
16 sharp features in the image.
17
18 Input: Edge images - vertical and horizontal
19 Window size (neighborhood size)
20 Output: Lambda, strength of pixel neighborhood
21
22 Given the edge images, we compute strength based
23 on how strong the edges are within each neighborhood.
24
25**/
26
27F2D* calcGoodFeature(F2D* verticalEdgeImage, F2D* horizontalEdgeImage, int cols, int rows, int winSize)
28{
29 int i, j, k, ind;
30 F2D *verticalEdgeSq, *horizontalEdgeSq, *horzVertEdge;
31 F2D *tr, *det, *lambda;
32 F2D *cummulative_verticalEdgeSq, *cummulative_horzVertEdge, *cummulative_horizontalEdgeSq;
33
34 verticalEdgeSq = fMallocHandle(rows, cols);
35 horzVertEdge = fMallocHandle(rows, cols);
36 horizontalEdgeSq = fMallocHandle(rows, cols);
37
38 for( i=0; i<rows; i++)
39 {
40 for( j=0; j<cols; j++)
41 {
42 subsref(verticalEdgeSq,i,j) = subsref(verticalEdgeImage,i,j) * subsref(verticalEdgeImage,i,j);
43 subsref(horzVertEdge,i,j) = subsref(verticalEdgeImage,i,j) * subsref(horizontalEdgeImage,i,j);
44 subsref(horizontalEdgeSq,i,j) = subsref(horizontalEdgeImage,i,j) * subsref(horizontalEdgeImage,i,j);
45 }
46 }
47
48 cummulative_verticalEdgeSq = calcAreaSum(verticalEdgeSq, cols, rows, winSize);
49 cummulative_horzVertEdge = calcAreaSum(horzVertEdge, cols, rows, winSize);
50 cummulative_horizontalEdgeSq = calcAreaSum(horizontalEdgeSq, cols, rows, winSize);
51
52 tr = fMallocHandle(rows, cols);
53 det = fMallocHandle(rows, cols);
54 lambda = fMallocHandle(rows, cols);
55
56 for( i=0; i<rows; i++)
57 {
58 for( j=0; j<cols; j++)
59 {
60 subsref(tr,i,j) = subsref(cummulative_verticalEdgeSq,i,j) + subsref(cummulative_horizontalEdgeSq,i,j);
61 subsref(det,i,j) = subsref(cummulative_verticalEdgeSq,i,j) * subsref(cummulative_horizontalEdgeSq,i,j) - subsref(cummulative_horzVertEdge,i,j) * subsref(cummulative_horzVertEdge,i,j);
62 subsref(lambda,i,j) = ( subsref(det,i,j) / (subsref(tr,i,j)+0.00001) ) ;
63 }
64 }
65
66 fFreeHandle(verticalEdgeSq);
67 fFreeHandle(horzVertEdge);
68 fFreeHandle(horizontalEdgeSq);
69
70 fFreeHandle(cummulative_verticalEdgeSq);
71 fFreeHandle(cummulative_horzVertEdge);
72 fFreeHandle(cummulative_horizontalEdgeSq);
73
74 fFreeHandle(tr);
75 fFreeHandle(det);
76
77 return lambda;
78}