1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
25 Gaussian additive noise example.
36 static void help(const char *app
)
38 printf("usage: %s -s float -m float input.img output.img\n\n", app
);
39 printf(" -s [0,1] sigma in pixels\n");
40 printf(" -m [0,1] mu in pixels\n");
43 int main(int argc
, char *argv
[])
46 float sigma
= 0.1, mu
= 0.1;
49 while ((opt
= getopt(argc
, argv
, "s:m:")) != -1) {
63 if (argc
- optind
!= 2) {
68 img
= GP_LoadImage(argv
[optind
], NULL
);
71 fprintf(stderr
, "Failed to load image '%s': %s\n",
72 argv
[optind
], strerror(errno
));
76 GP_Pixmap
*res
= GP_FilterGaussianNoiseAddAlloc(img
, sigma
, mu
, NULL
);
78 if (GP_SaveImage(res
, argv
[optind
+ 1], NULL
)) {
79 fprintf(stderr
, "Failed to save image '%s': %s",
80 argv
[optind
+ 1], strerror(errno
));