PIPS
gaussian_noise_reduce.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "tools.h"
+ Include dependency graph for gaussian_noise_reduce.c:

Go to the source code of this file.

Functions

void gaussian_noise_reduce (int w, int h, float img_in[w *h], float img_out[w *h])
 
int main (int argc, char **argv)
 

Function Documentation

◆ gaussian_noise_reduce()

void gaussian_noise_reduce ( int  w,
int  h,
float  img_in[w *h],
float  img_out[w *h] 
)

Definition at line 12 of file gaussian_noise_reduce.c.

13 {
14  int x, y, max_x, max_y;
15  max_x = w - 2;
16  max_y = w * (h - 2);
17  for (y = w * 2; y < max_y; y += w) {
18  for (x = 2; x < max_x; x++) {
19  img_out[x + y] = (2 * img_in[x + y - 2 - w - w] +
20  4 * img_in[x + y - 1 - w - w] +
21  5 * img_in[x + y - w - w] +
22  4 * img_in[x + y + 1 - w - w] +
23  2 * img_in[x + y + 2 - w - w] +
24  4 * img_in[x + y - 2 - w] +
25  9 * img_in[x + y - 1 - w] +
26  12 * img_in[x + y - w] +
27  9 * img_in[x + y + 1 - w] +
28  4 * img_in[x + y + 2 - w] +
29  5 * img_in[x + y - 2] +
30  12 * img_in[x + y - 1] +
31  15 * img_in[x + y] +
32  12 * img_in[x + y + 1] +
33  5 * img_in[x + y + 2] +
34  4 * img_in[x + y - 2 + w] +
35  9 * img_in[x + y - 1 + w] +
36  12 * img_in[x + y + w] +
37  9 * img_in[x + y + 1 + w] +
38  4 * img_in[x + y + 2 + w] +
39  2 * img_in[x + y - 2 + w + w] +
40  4 * img_in[x + y - 1 + w + w] +
41  5 * img_in[x + y + w + w] +
42  4 * img_in[x + y + 1 + w + w] +
43  2 * img_in[x + y + 2 + w + w]) / 159;
44  }
45  }
46 }
static char * x
Definition: split_file.c:159

References x.

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 48 of file gaussian_noise_reduce.c.

48  {
49  int n;
50  float (*in)[n*n], (*out)[n*n];
51  int i;
52  if (argc < 3)
53  {
54  fprintf(stderr, "Usage: %s size data_file\n", argv[0]);
55  return 1;
56  }
57  n = atoi(argv[1]);
58  in=malloc(n*n);
59  out=malloc(n*n);
60  init_data_file(argv[2]);
61  init_data_float(in, n*n);
63  for(i=0;i<n*n;i++) {
64  (*out)[i]=0;
65  }
66  gaussian_noise_reduce(n,n,*in,*out);
67  print_array_float(out, n*n);
68  free(in);free(out);
69  return 0;
70 }
static FILE * out
Definition: alias_check.c:128
void gaussian_noise_reduce(int w, int h, float img_in[w *h], float img_out[w *h])
void * malloc(YYSIZE_T)
void free(void *)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
void close_data_file()
Definition: tools.c:48
void print_array_float(const char *name, const float *arr, const unsigned int n)
Definition: tools.c:54
int init_data_float(float *ptr, const unsigned int n)
Definition: tools.c:125
void init_data_file(const char *data_file)
Definition: tools.c:36

References close_data_file(), fprintf(), free(), gaussian_noise_reduce(), init_data_file(), init_data_float(), malloc(), out, and print_array_float().

+ Here is the call graph for this function: