Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -: 0:Source:common/calcSobel_dX.c
- -: 0:Graph:calcSobel_dX.gcno
- -: 0:Data:calcSobel_dX.gcda
- -: 0:Runs:1
- -: 0:Programs:1
- -: 1:/********************************
- -: 2:Author: Sravanthi Kota Venkata
- -: 3:********************************/
- -: 4:
- -: 5:#include <stdio.h>
- -: 6:#include <stdlib.h>
- -: 7:#include "sdvbs_common.h"
- -: 8:
- 9: 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:
- 9: 18: rows = imageIn->height;
- 9: 19: cols = imageIn->width;
- -: 20:
- 9: 21: imageOut = fSetArray(rows, cols, 0);
- 9: 22: tempOut = fSetArray(rows, cols, 0);
- 9: 23: kernel_1 = fMallocHandle(1, 3);
- 9: 24: kernel_2 = fMallocHandle(1, 3);
- -: 25:
- 9: 26: asubsref(kernel_1,0) = 1;
- 9: 27: asubsref(kernel_1,1) = 2;
- 9: 28: asubsref(kernel_1,2) = 1;
- -: 29:
- -: 30: kernelSize = 3;
- -: 31: kernelSum_1 = 4;
- -: 32:
- 9: 33: asubsref(kernel_2,0) = 1;
- 9: 34: asubsref(kernel_2,1) = 0;
- 9: 35: asubsref(kernel_2,2) = -1;
- -: 36:
- -: 37: kernelSum_2 = 2;
- -: 38:
- -: 39: startCol = 1;
- 9: 40: endCol = cols - 1;
- -: 41: halfKernel = 1;
- -: 42:
- -: 43: startRow = 1;
- 9: 44: endRow = rows - 1;
- -: 45:
- 7551: 46: for(i=startRow; i<endRow; i++)
- -: 47: {
- 12399636: 48: for(j=startCol; j<endCol; j++)
- -: 49: {
- -: 50: temp = 0;
- 37198908: 51: for(k=-halfKernel; k<=halfKernel; k++)
- -: 52: {
- 37198908: 53: temp += subsref(imageIn,i,j+k) * asubsref(kernel_2,k+halfKernel);
- -: 54: }
- 12399636: 55: subsref(tempOut,i,j) = temp/kernelSum_2;
- -: 56: }
- -: 57: }
- -: 58:
- 7542: 59: for(i=startRow; i<endRow; i++)
- -: 60: {
- 12399636: 61: for(j=startCol; j<endCol; j++)
- -: 62: {
- -: 63: temp = 0;
- 37198908: 64: for(k=-halfKernel; k<=halfKernel; k++)
- -: 65: {
- 37198908: 66: temp += subsref(tempOut,(i+k),j) * asubsref(kernel_1,k+halfKernel);
- -: 67: }
- 12399636: 68: subsref(imageOut,i,j) = temp/(float)kernelSum_1;
- -: 69: }
- -: 70: }
- -: 71:
- 9: 72: fFreeHandle(tempOut);
- 9: 73: fFreeHandle(kernel_1);
- 9: 74: fFreeHandle(kernel_2);
- 9: 75: return imageOut;
- -: 76:
- -: 77:}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement