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