forked from npd/imgutils
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathawgn.cpp
More file actions
34 lines (28 loc) · 710 Bytes
/
Copy pathawgn.cpp
File metadata and controls
34 lines (28 loc) · 710 Bytes
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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//#include "smapa.h"
#include "random.c"
extern "C" {
#include "iio.h"
}
//SMART_PARAMETER_SILENT(SRAND, 0)
#define SRAND() (0)
int main(int c, char *v[])
{
if (c != 4 && c != 3 && c != 2) {
fprintf(stderr, "usage:\n\t%s sigma [in [out]]\n", *v);
// 0 1 2 3
return EXIT_FAILURE;
}
float s = atof(v[1]);
char *in = c > 2 ? v[2] : (char*) "-";
char *out = c > 3 ? v[3] : (char*) "-";
int w, h, pd;
float *x = iio_read_image_float_vec(in, &w, &h, &pd);
xsrand(SRAND());
for (int i = 0; i < w*h*pd; i++)
x[i] += s * random_normal();
iio_save_image_float_vec(out, x, w, h, pd);
return EXIT_SUCCESS;
}