-
Notifications
You must be signed in to change notification settings - Fork 110
/
p_laplace3x3.c
59 lines (54 loc) · 1.32 KB
/
p_laplace3x3.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
59
#include <pal.h>
/**
* A Laplace 3x3 convolution filter (m) with the Laplace operators defined as:
*
* | 0 -1 0 |
* LA3 = | -1 4 -1 |
* | 0 -1 0 |
*
* Notes: cols must be a multiple of 2
*
* @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_laplace3x3_f32(const float *x, float *r, int rows, int cols)
{
int ia, ja;
float LA;
const float *px;
float *pr;
px = x;
pr = r;
for (ia = 1; ia <= (rows - 2); ia++) {
for (ja = 1; ja <= (cols - 2); ja++) {
LA = 0;
px++;
LA -= (*px++);
px++;
px += cols - 3;
LA -= (*px++);
LA += (*px++) * 4;
LA -= (*px++);
px += cols - 3;
px++;
LA -= (*px++);
px++;
px += cols - 3;
*pr = LA;
px += 1 - 3 * cols; // advance mask matrix in one column.
pr++;
}
px = px + 2; // at the last column in a row, advance pointer to the
// beginning of next row.
// pr = pr + 2;
}
return;
}