1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/********************************
Author: Sravanthi Kota Venkata
********************************/
#include "sdvbs_common.h"
F2D* imageResize(F2D* imageIn)
{
int m, k, rows, cols;
F2D *imageOut;
I2D *kernel;
float tempVal;
int kernelSize, startCol, endCol, halfKernel, startRow, endRow, i, j, kernelSum;
int outputRows, outputCols;
F2D *temp;
rows = imageIn->height;
cols = imageIn->width;
// level 1 is the base image.
outputRows = floor((rows+1)/2);
outputCols = floor((cols+1)/2);
temp = fSetArray(rows, outputCols, 0);
imageOut = fSetArray(outputRows, outputCols, 0);
kernel = iMallocHandle(1, 5);
asubsref(kernel,0) = 1;
asubsref(kernel,1) = 4;
asubsref(kernel,2) = 6;
asubsref(kernel,3) = 4;
asubsref(kernel,4) = 1;
kernelSize = 5;
kernelSum = 16;
startCol = 2;
endCol = cols - 2;
halfKernel = 2;
startRow = 2;
endRow = rows - 2;
for(i=startRow; i<endRow; i++)
{
m = 0;
for(j=startCol; j<endCol; j+=2)
{
tempVal = 0;
for(k=-halfKernel; k<=halfKernel; k++)
{
tempVal += subsref(imageIn,i,j+k) * asubsref(kernel,k+halfKernel);
}
subsref(temp,i,m) = tempVal/kernelSum;
m = m+1;
}
}
m = 0;
for(i=startRow; i<endRow; i+=2)
{
for(j=0; j<outputCols; j++)
{
tempVal = 0;
for(k=-halfKernel; k<=halfKernel; k++)
{
tempVal += subsref(temp,(i+k),j) * asubsref(kernel,k+halfKernel);
}
subsref(imageOut,m,j) = (tempVal/kernelSum);
}
m = m+1;
}
fFreeHandle(temp);
iFreeHandle(kernel);
return imageOut;
}
|