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