This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via b45098c71ca5dab7345e2b2f704ae6452a7b52cb (commit) from 40459eab2c4a3af4a5eccd1b3cbe1bd94353f9c7 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/b45098c71ca5dab7345e2b2f704ae6452a7b5...
commit b45098c71ca5dab7345e2b2f704ae6452a7b52cb Author: Cyril Hrubis metan@ucw.cz Date: Tue Jun 5 15:18:09 2012 +0200
filters: Add noise filter.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index abdf546..1bc7360 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -354,6 +354,28 @@ static GP_RetCode contrast(GP_Context **c, const char *params) return GP_ESUCCESS; }
+/* noise */ +static struct param noise_params[] = { + {"ratio", PARAM_FLOAT, "noise", NULL, NULL}, + {NULL, 0, NULL, NULL, NULL} +}; + +static GP_RetCode noise(GP_Context **c, const char *params) +{ + float rat; + + if (param_parse(params, noise_params, "noise", param_err, &rat)) + return GP_EINVAL; + + GP_FILTER_PARAMS((*c)->pixel_type, filter_params); + + GP_FilterParamSetFloatAll(filter_params, rat); + + GP_FilterNoise(*c, *c, filter_params, progress_callback); + + return GP_ESUCCESS; +} + /* invert */
static struct param invert_params[] = { @@ -675,6 +697,7 @@ static struct filter filter_table[] = { {"contrast", "alter image contrast", contrast_params, contrast}, {"invert", "inverts image", invert_params, invert}, {"add_noise", "adds noise", add_noise_params, add_noise}, + {"noise", "adds noise", noise_params, noise}, {"blur", "gaussian blur", blur_params, blur}, {"dither", "dithers bitmap", dither_params, dither}, {"arithmetic", "arithmetic operation", arithmetic_params, arithmetic}, diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h index 1ab3756..31e9747 100644 --- a/include/filters/GP_Point.h +++ b/include/filters/GP_Point.h @@ -72,6 +72,12 @@ GP_Context *GP_FilterInvert(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback);
/* + * Noise filter. + */ +GP_Context *GP_FilterNoise(const GP_Context *src, GP_Context *dst, + GP_FilterParam ratio[], GP_ProgressCallback *callback); + +/* * Generic slow point filter. * * The filter_callback[] is expected to be filled with pointers diff --git a/libs/filters/GP_Noise.gen.c.t b/libs/filters/GP_Noise.gen.c.t new file mode 100644 index 0000000..7afca65 --- /dev/null +++ b/libs/filters/GP_Noise.gen.c.t @@ -0,0 +1,34 @@ +%% extends "filter.point.c.t" + +{% block descr %}Noise filter -- Adds noise to an image.{% endblock %} + +%% block body + +{{ filter_point_include() }} + +%% macro filter_op(chann_name, chann_size) +{{ chann_name }} = {{ chann_name }} + (random() % ({{ chann_name }}_max * 2)) - {{ chann_name }}_max; +{{ filter_clamp_val(chann_name, chann_size) }} +%% endmacro + +/* + * Generated noise filters. + */ +%% call(pt) filter_point_per_channel('Noise', 'GP_FilterParam ratio[]', filter_op) +{{ filter_params(pt, 'ratio', 'float ', '_rat', 'f') }} +%% for chann in pt.chanslist + int {{ chann[0] }}_max = {{ chann[0] }}_rat * {{ 2 ** chann[2] - 1}} + 0.5; +%% endfor +%% endcall + +/* + * Generated noise filters for pixels with one channel. + */ +%% call(ps) filter_point_per_bpp('Noise', 'GP_FilterParam ratio[]', filter_op) +{{ filter_param(ps, 'ratio', 'float ', '_rat', 'f') }} + int pix_max = pix_rat * {{ 2 ** ps.size - 1}} + 0.5; +%% endcall + +{{ filter_functions('Noise', 'GP_FilterParam ratio[]', 'ratio') }} + +%% endblock body diff --git a/libs/filters/Makefile b/libs/filters/Makefile index 4bed64a..49993aa 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -3,7 +3,7 @@ TOPDIR=../.. STATS_FILTERS=GP_Histogram.gen.c
POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c- GP_Point.gen.c + GP_Point.gen.c GP_Noise.gen.c
ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 25 ++++++++++++++++++++++++- include/filters/GP_Point.h | 6 ++++++ libs/filters/GP_Noise.gen.c.t | 34 ++++++++++++++++++++++++++++++++++ libs/filters/Makefile | 2 +- 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 libs/filters/GP_Noise.gen.c.t
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.