PandA-2024.02
filter.c
Go to the documentation of this file.
1 #include "filter.h"
2 #include "mypgm.h"
3 
4 
5 #define MAX_PIPELINE_DEPTH 10
7 
8 
9 int add_filter(unsigned int pos, int (*filter)(unsigned char *, unsigned char *, unsigned int, unsigned int))
10 {
11  pipeline[pos] = filter;
12  return 0;
13 }
14 
15 
16 void execute(unsigned char *in, unsigned char *out, unsigned int x_size, unsigned int y_size)
17 {
18  int i = 0;
19  int (*fun)(unsigned char *, unsigned char *, unsigned int, unsigned int);
20  for (i = 0; i < MAX_PIPELINE_DEPTH; i++) {
21  if (pipeline[i] == 0) break;
22 
23  fun = (int (*)(unsigned char *, unsigned char *, unsigned int, unsigned int)) pipeline[i];
24  int res = fun(in, out, x_size, y_size);
25  if (res != 0) return;
26 
27  unsigned char * tmp = in;
28  in = out;
29  out = tmp;
30  }
31 
32  // copy the content of in on out when the number of applied filter
33  // is odd.
34  if (!(i % 2))
35  {
36  int x, y;
37  for (y = 0; y < y_size; y++) {
38  for (x = 0; x < x_size; x++) {
39  *(out + y + x * MAX_IMAGESIZE) = *(in + y + x * MAX_IMAGESIZE);
40  }
41  }
42  }
43 }
44 
#define MAX_PIPELINE_DEPTH
Definition: filter.c:5
void filter(int y, int input[][DIMENSION_X], int *output)
a 3x3 box filter. Filter an entire row of the matrix in one call.
Definition: boxfilter.c:26
#define MAX_IMAGESIZE
Definition: mypgm.h:7
void * pipeline[MAX_PIPELINE_DEPTH]
Definition: filter.c:6
void execute(unsigned char *in, unsigned char *out, unsigned int x_size, unsigned int y_size)
Definition: filter.c:16
int add_filter(unsigned int pos, int(*filter)(unsigned char *, unsigned char *, unsigned int, unsigned int))
Definition: filter.c:9
x
Return the smallest n such that 2^n >= _x.
int fun(float *A, float *invA, float *b, float *x, float *I)

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13