6
7
* filter: filter to be applied
7
8
* input: input buffers
8
9
**************************************************************/
9
CELL apply_filter(FILTER * filter, CELL ** input)
10
DCELL apply_filter(FILTER * filter, DCELL ** input)
19
divisor = filter->divisor;
20
matrix = filter->matrix;
12
int size = filter->size;
13
double **matrix = filter->matrix;
14
double divisor = filter->divisor;
23
for (r = 0; r < size; r++)
24
for (c = 0; c < size; c++)
25
v += input[r][c] * matrix[r][c];
26
/* zero divisor means compute a divisor. this is done by adding the
27
numbers is the divisor matrix where the corresponding cell value
30
20
if (divisor == 0) {
31
matrix = filter->dmatrix;
32
23
for (r = 0; r < size; r++)
33
for (c = 0; c < size; c++)
35
divisor += matrix[r][c];
24
for (c = 0; c < size; c++) {
25
if (Rast_is_d_null_value(&input[r][c]))
27
v += input[r][c] * matrix[r][c];
28
divisor += filter->dmatrix[r][c];
35
Rast_set_d_null_value(&v, 1);
38
for (r = 0; r < size; r++)
39
for (c = 0; c < size; c++) {
40
if (Rast_is_d_null_value(&input[r][c])) {
41
Rast_set_d_null_value(&v, 1);
44
v += input[r][c] * matrix[r][c];
38
/* now round the result to nearest integer. negative numbers are rounded
39
a little differently than non-negative numbers
42
if (round = divisor / 2) {
43
if ((round > 0 && v > 0) || (round < 0 && v < 0))