forked from parallella/pal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_gauss3x3.c
58 lines (51 loc) · 1.08 KB
/
p_gauss3x3.c
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
#include <pal.h>
/*
* A 3x3 gauss smoothing filter with the following convolution matrix
*
* |1 2 1|
* M =|2 4 2| * 1/16
* |1 2 1|
*
* @param x Pointer to input image, a 2D array of size 'rows' x 'cols'
*
* @param r Pointer to output image
*
* @param rows Number of rows in input image
*
* @param cols Number of columns in input image
*
* @return None
*
*/
void p_gauss3x3_f32(const float *x, float *r, int rows, int cols)
{
int i, j;
int rm2 = rows - 2;
int cm2 = cols - 2;
int cj = 1 + 2 * cols;
float P;
const float *px;
float *pr;
px = x;
pr = r;
for (i = 0; i < rm2; i++) {
for (j = 0; j < cm2; j++) {
P = (*px++);
P += (*px++) * 2;
P += (*px);
px += cm2;
P += (*px++) * 2;
P += (*px++) * 4;
P += (*px) * 2;
px += cm2;
P += (*px++);
P += (*px++) * 2;
P += (*px);
px -= cj;
*pr = P * M_DIV16;
pr++;
}
px = px + 2;
}
return;
}