summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/c/calcSobel_dY.c
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/c/calcSobel_dY.c
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/common/c/calcSobel_dY.c')
-rw-r--r--SD-VBS/common/c/calcSobel_dY.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/SD-VBS/common/c/calcSobel_dY.c b/SD-VBS/common/c/calcSobel_dY.c
new file mode 100644
index 0000000..d2ed379
--- /dev/null
+++ b/SD-VBS/common/c/calcSobel_dY.c
@@ -0,0 +1,79 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "sdvbs_common.h"
6
7F2D* calcSobel_dY(F2D* imageIn)
8{
9 int rows, cols;
10 I2D *kernel_1, *kernel_2;
11 float temp;
12 int kernelSize, startCol, endCol, halfKernel, startRow, endRow, i, j, kernelSum;
13 int k, kernelSum_2, outputRows, outputCols;
14 F2D *imageOut, *tempOut;
15 float kernelSum_1;
16
17 rows = imageIn->height;
18 cols = imageIn->width;
19
20 // level 1 is the base image.
21
22 outputRows = rows;
23 outputCols = cols;
24
25 imageOut = fSetArray(outputRows, outputCols, 0);
26 tempOut = fSetArray(outputRows, outputCols, 0);
27 kernel_1 = iMallocHandle(1, 3);
28 kernel_2 = iMallocHandle(1, 3);
29
30 asubsref(kernel_1,0) = 1;
31 asubsref(kernel_1,1) = 0;
32 asubsref(kernel_1,2) = -1;
33 kernelSize = 3;
34 kernelSum_1 = 2.0;
35
36 asubsref(kernel_2,0) = 1;
37 asubsref(kernel_2,1) = 2;
38 asubsref(kernel_2,2) = 1;
39 kernelSum_2 = 4;
40
41 startCol = 1;
42 endCol = cols - 1;
43 halfKernel = 1;
44
45 startRow = 1;
46 endRow = rows - 1;
47
48 for(i=startRow; i<endRow; i++)
49 {
50 for(j=startCol; j<endCol; j++)
51 {
52 temp = 0;
53 for(k=-halfKernel; k<=halfKernel; k++)
54 {
55 temp += subsref(imageIn,(i+k),j) * asubsref(kernel_1,k+halfKernel);
56 }
57 subsref(tempOut,i,j) = temp/kernelSum_1;
58 }
59 }
60
61 for(i=startRow; i<endRow; i++)
62 {
63 for(j=startCol; j<endCol; j++)
64 {
65 temp = 0;
66 for(k=-halfKernel; k<=halfKernel; k++)
67 {
68 temp += subsref(tempOut,i,j+k) * asubsref(kernel_2,k+halfKernel);
69 }
70 subsref(imageOut,i,j) = temp/(float)kernelSum_2;
71 }
72 }
73
74 fFreeHandle(tempOut);
75 iFreeHandle(kernel_1);
76 iFreeHandle(kernel_2);
77 return imageOut;
78
79}