diff options
Diffstat (limited to 'SD-VBS/common/c/calcSobel_dY.c')
| -rw-r--r-- | SD-VBS/common/c/calcSobel_dY.c | 79 |
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 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include "sdvbs_common.h" | ||
| 6 | |||
| 7 | F2D* 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 | } | ||
