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/tracking/src/c/calcGoodFeature.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/tracking/src/c/calcGoodFeature.c')
| -rw-r--r-- | SD-VBS/benchmarks/tracking/src/c/calcGoodFeature.c | 78 |
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 | /******************************** | ||
| 2 | Author: 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 | |||
| 27 | F2D* 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 | } | ||
