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/common/c/calcSobel_dX.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/common/c/calcSobel_dX.c')
-rw-r--r-- | SD-VBS/common/c/calcSobel_dX.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/SD-VBS/common/c/calcSobel_dX.c b/SD-VBS/common/c/calcSobel_dX.c new file mode 100644 index 0000000..4be5845 --- /dev/null +++ b/SD-VBS/common/c/calcSobel_dX.c | |||
@@ -0,0 +1,77 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include "sdvbs_common.h" | ||
8 | |||
9 | F2D* calcSobel_dX(F2D* imageIn) | ||
10 | { | ||
11 | int rows, cols; | ||
12 | F2D *kernel_1, *kernel_2; | ||
13 | float temp; | ||
14 | int kernelSize, startCol, endCol, halfKernel, startRow, endRow, i, j, kernelSum; | ||
15 | int k, kernelSum_1, kernelSum_2; | ||
16 | F2D *imageOut, *tempOut; | ||
17 | |||
18 | rows = imageIn->height; | ||
19 | cols = imageIn->width; | ||
20 | |||
21 | imageOut = fSetArray(rows, cols, 0); | ||
22 | tempOut = fSetArray(rows, cols, 0); | ||
23 | kernel_1 = fMallocHandle(1, 3); | ||
24 | kernel_2 = fMallocHandle(1, 3); | ||
25 | |||
26 | asubsref(kernel_1,0) = 1; | ||
27 | asubsref(kernel_1,1) = 2; | ||
28 | asubsref(kernel_1,2) = 1; | ||
29 | |||
30 | kernelSize = 3; | ||
31 | kernelSum_1 = 4; | ||
32 | |||
33 | asubsref(kernel_2,0) = 1; | ||
34 | asubsref(kernel_2,1) = 0; | ||
35 | asubsref(kernel_2,2) = -1; | ||
36 | |||
37 | kernelSum_2 = 2; | ||
38 | |||
39 | startCol = 1; | ||
40 | endCol = cols - 1; | ||
41 | halfKernel = 1; | ||
42 | |||
43 | startRow = 1; | ||
44 | endRow = rows - 1; | ||
45 | |||
46 | for(i=startRow; i<endRow; i++) | ||
47 | { | ||
48 | for(j=startCol; j<endCol; j++) | ||
49 | { | ||
50 | temp = 0; | ||
51 | for(k=-halfKernel; k<=halfKernel; k++) | ||
52 | { | ||
53 | temp += subsref(imageIn,i,j+k) * asubsref(kernel_2,k+halfKernel); | ||
54 | } | ||
55 | subsref(tempOut,i,j) = temp/kernelSum_2; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | for(i=startRow; i<endRow; i++) | ||
60 | { | ||
61 | for(j=startCol; j<endCol; j++) | ||
62 | { | ||
63 | temp = 0; | ||
64 | for(k=-halfKernel; k<=halfKernel; k++) | ||
65 | { | ||
66 | temp += subsref(tempOut,(i+k),j) * asubsref(kernel_1,k+halfKernel); | ||
67 | } | ||
68 | subsref(imageOut,i,j) = temp/(float)kernelSum_1; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | fFreeHandle(tempOut); | ||
73 | fFreeHandle(kernel_1); | ||
74 | fFreeHandle(kernel_2); | ||
75 | return imageOut; | ||
76 | |||
77 | } | ||