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 34e163b7791258eea5d8a0fc467e84f983e4273c (commit) via 3ae0e5346bd38347c6642829238bf2db9d4716a3 (commit) via a5806c8cd1c03efe50cef124116278d067fdc793 (commit) via acb23fffacdae415b778e2effdc506d8d3b8b420 (commit) via 280e32f1a1d6f25018f19a0a793f470144650eef (commit) via 6a4ef1c559652d3f2e1d7c1e69d47f214364a9d6 (commit) via 445b1c8edfd8a95ad0f40e13f20eade2f6fbed10 (commit) via ef943c2310c1345dbc8bd34c3cdd26648ed79420 (commit) via 6a0865b80f90e2397d90d13e836b0db3f8aaa372 (commit) via ddaf9058d046bbde16edfe2c4655a5690b043883 (commit) from ed36869f7b525df87a66c7403485f8ddd8491457 (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/34e163b7791258eea5d8a0fc467e84f983e42...
commit 34e163b7791258eea5d8a0fc467e84f983e4273c Author: Cyril Hrubis metan@ucw.cz Date: Sat Nov 9 00:37:52 2013 +0100
doc: filters_python: Add rotation and symmetry filters.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/filters_python.txt b/doc/filters_python.txt index 6802510..1d374e3 100644 --- a/doc/filters_python.txt +++ b/doc/filters_python.txt @@ -114,6 +114,109 @@ The pixel channel values are quantized into number of levels.
include::images/posterize/images.txt[]
+Rotations and Mirroring +~~~~~~~~~~~~~~~~~~~~~~~ + +MirrorH +^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Mirrors in-place image horizontally + img.filters.MirrorH(img, callback=None) + + # Mirrors image horizontally + res = img.filters.MirrorHAlloc(callback=None) + +------------------------------------------------------------------------------- + +Mirrors image horizontally. + +include::images/mirror_h/images.txt[] + +MirrorV +^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Mirrors in-place image vertically + img.filters.MirrorV(img, callback=None) + + # Mirrors image vertically + res = img.filters.MirrorVAlloc(callback=None) + +------------------------------------------------------------------------------- + +Mirrors image vertically. + +include::images/mirror_v/images.txt[] + +Rotate90 +^^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Rotate in-place by 90 degrees + img.filters.Rotate90(img, callback=None) + + # Rotate by 90 degrees + res = img.filters.Rotate90Alloc(callback=None) + +------------------------------------------------------------------------------- + +Rotate image by 90 degrees clockwise. + +include::images/rotate_90/images.txt[] + +Rotate180 +^^^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Rotate in-place by 180 degrees + img.filters.Rotate180(img, callback=None) + + # Rotate by 180 degrees + res = img.filters.Rotate180Alloc(callback=None) + +------------------------------------------------------------------------------- + +Rotate image by 180 degrees clockwise. + +include::images/rotate_180/images.txt[] + +Rotate270 +^^^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Rotate in-place by 270 degrees + img.filters.Rotate270(img, callback=None) + + # Rotate by 270 degrees + res = img.filters.Rotate270Alloc(callback=None) + +------------------------------------------------------------------------------- + +Rotate image by 270 degrees clockwise. + +include::images/rotate_270/images.txt[] + Gaussian Additive Noise ~~~~~~~~~~~~~~~~~~~~~~~
@@ -136,6 +239,7 @@ interval.
include::images/gaussian_noise/images.txt[]
+ Laplacian Edge Sharpening ~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/images/mirror_h/images.txt b/doc/images/mirror_h/images.txt new file mode 100644 index 0000000..14edc6b --- /dev/null +++ b/doc/images/mirror_h/images.txt @@ -0,0 +1,8 @@ +.Original Image; Mirrored Horizontally +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/mirror_h/lenna_small_.png[ + "Mirrored Horizontally ", + link="images/mirror_h/lenna_.png"] + diff --git a/doc/images/mirror_h/lenna_.png b/doc/images/mirror_h/lenna_.png new file mode 100644 index 0000000..90d4dc8 Binary files /dev/null and b/doc/images/mirror_h/lenna_.png differ diff --git a/doc/images/mirror_h/lenna_small_.png b/doc/images/mirror_h/lenna_small_.png new file mode 100644 index 0000000..b5625a0 Binary files /dev/null and b/doc/images/mirror_h/lenna_small_.png differ diff --git a/doc/images/mirror_v/images.txt b/doc/images/mirror_v/images.txt new file mode 100644 index 0000000..b37b76e --- /dev/null +++ b/doc/images/mirror_v/images.txt @@ -0,0 +1,8 @@ +.Original Image; Mirrored Vertically +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/mirror_v/lenna_small_.png[ + "Mirrored Vertically ", + link="images/mirror_v/lenna_.png"] + diff --git a/doc/images/mirror_v/lenna_.png b/doc/images/mirror_v/lenna_.png new file mode 100644 index 0000000..6bb590c Binary files /dev/null and b/doc/images/mirror_v/lenna_.png differ diff --git a/doc/images/mirror_v/lenna_small_.png b/doc/images/mirror_v/lenna_small_.png new file mode 100644 index 0000000..bae1469 Binary files /dev/null and b/doc/images/mirror_v/lenna_small_.png differ diff --git a/doc/images/regen.py b/doc/images/regen.py index ace7e6a..6aaeb34 100755 --- a/doc/images/regen.py +++ b/doc/images/regen.py @@ -81,6 +81,26 @@ def main(): [[2], [3], [4], [5], [6]], 'images/posterize/', 'Posterize')
+ imggen.gen(filters.MirrorHAlloc, [], + [[]], + 'images/mirror_h/', 'Mirrored Horizontally') + + imggen.gen(filters.MirrorVAlloc, [], + [[]], + 'images/mirror_v/', 'Mirrored Vertically') + + imggen.gen(filters.Rotate90Alloc, [], + [[]], + 'images/rotate_90/', 'Rotated by 90 degrees') + + imggen.gen(filters.Rotate180Alloc, [], + [[]], + 'images/rotate_180/', 'Rotated by 180 degrees') + + imggen.gen(filters.Rotate270Alloc, [], + [[]], + 'images/rotate_270/', 'Rotated by 270 degrees') + imggen.gen(filters.GaussianBlurAlloc, ['xsig', 'ysig'], [[2, 2], [0, 4], [4, 0], [4, 4], [10, 10]], 'images/blur/', 'Gaussian Blur') diff --git a/doc/images/rotate_180/images.txt b/doc/images/rotate_180/images.txt new file mode 100644 index 0000000..c992eb5 --- /dev/null +++ b/doc/images/rotate_180/images.txt @@ -0,0 +1,8 @@ +.Original Image; Rotated by 180 degrees +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/rotate_180/lenna_small_.png[ + "Rotated by 180 degrees ", + link="images/rotate_180/lenna_.png"] + diff --git a/doc/images/rotate_180/lenna_.png b/doc/images/rotate_180/lenna_.png new file mode 100644 index 0000000..650a3cf Binary files /dev/null and b/doc/images/rotate_180/lenna_.png differ diff --git a/doc/images/rotate_180/lenna_small_.png b/doc/images/rotate_180/lenna_small_.png new file mode 100644 index 0000000..35df519 Binary files /dev/null and b/doc/images/rotate_180/lenna_small_.png differ diff --git a/doc/images/rotate_270/images.txt b/doc/images/rotate_270/images.txt new file mode 100644 index 0000000..7f1a560 --- /dev/null +++ b/doc/images/rotate_270/images.txt @@ -0,0 +1,8 @@ +.Original Image; Rotated by 270 degrees +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/rotate_270/lenna_small_.png[ + "Rotated by 270 degrees ", + link="images/rotate_270/lenna_.png"] + diff --git a/doc/images/rotate_270/lenna_.png b/doc/images/rotate_270/lenna_.png new file mode 100644 index 0000000..c93aaeb Binary files /dev/null and b/doc/images/rotate_270/lenna_.png differ diff --git a/doc/images/rotate_270/lenna_small_.png b/doc/images/rotate_270/lenna_small_.png new file mode 100644 index 0000000..7a43342 Binary files /dev/null and b/doc/images/rotate_270/lenna_small_.png differ diff --git a/doc/images/rotate_90/images.txt b/doc/images/rotate_90/images.txt new file mode 100644 index 0000000..d8e3f38 --- /dev/null +++ b/doc/images/rotate_90/images.txt @@ -0,0 +1,8 @@ +.Original Image; Rotated by 90 degrees +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/rotate_90/lenna_small_.png[ + "Rotated by 90 degrees ", + link="images/rotate_90/lenna_.png"] + diff --git a/doc/images/rotate_90/lenna_.png b/doc/images/rotate_90/lenna_.png new file mode 100644 index 0000000..897940c Binary files /dev/null and b/doc/images/rotate_90/lenna_.png differ diff --git a/doc/images/rotate_90/lenna_small_.png b/doc/images/rotate_90/lenna_small_.png new file mode 100644 index 0000000..8690302 Binary files /dev/null and b/doc/images/rotate_90/lenna_small_.png differ
http://repo.or.cz/w/gfxprim.git/commit/3ae0e5346bd38347c6642829238bf2db9d471...
commit 3ae0e5346bd38347c6642829238bf2db9d4716a3 Author: Cyril Hrubis metan@ucw.cz Date: Sat Nov 9 00:30:30 2013 +0100
build: Update list of filter exported symbols.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt index 8350180..9b5b73b 100644 --- a/build/syms/Filters_symbols.txt +++ b/build/syms/Filters_symbols.txt @@ -14,6 +14,12 @@ GP_FilterBrightnessExAlloc GP_FilterContrastEx GP_FilterContrastExAlloc
+GP_FilterBrightnessContrastEx +GP_FilterBrightnessContrastExAlloc + +GP_FilterPosterizeEx +GP_FilterPosterizeExAlloc + GP_FilterAddition GP_FilterAdditionAlloc GP_FilterAddition_Raw @@ -83,9 +89,6 @@ GP_FilterMultiply GP_FilterMultiplyAlloc GP_FilterMultiply_Raw
-GP_FilterNoise -GP_FilterNoise_Raw - GP_FilterParamChannel GP_FilterParamChannels GP_FilterParamCheckChannels @@ -107,9 +110,6 @@ GP_FilterParamSetPtrAll GP_FilterParamSetUInt GP_FilterParamSetUIntAll
-GP_FilterPoint -GP_FilterPoint_Raw - GP_FilterResize GP_FilterResizeAlloc
http://repo.or.cz/w/gfxprim.git/commit/a5806c8cd1c03efe50cef124116278d067fdc...
commit a5806c8cd1c03efe50cef124116278d067fdc793 Author: Cyril Hrubis metan@ucw.cz Date: Sat Nov 9 00:28:42 2013 +0100
filters: Remove unused GP_Noise.gen.c.t and GP_Point.gen.c.t
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/filters/GP_Noise.gen.c.t b/libs/filters/GP_Noise.gen.c.t deleted file mode 100644 index e48d72c..0000000 --- a/libs/filters/GP_Noise.gen.c.t +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -%% 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/GP_Point.gen.c.t b/libs/filters/GP_Point.gen.c.t deleted file mode 100644 index 74c96b2..0000000 --- a/libs/filters/GP_Point.gen.c.t +++ /dev/null @@ -1,57 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -%% extends "filter.point.c.t" - -%% block descr -Point filters -- General point filter. -%% endblock - -%% block body - -{{ filter_point_include() }} - -typedef uint32_t (*func)(uint32_t, uint8_t, GP_FilterParam *priv); - -%% macro filter_op(chan_name, chan_size) -{{ chan_name }} = {{ chan_name }}_func({{ chan_name }}, {{ chan_size }}, {{ chan_name }}_priv); -%% endmacro - -/* - * Generated point filters for pixels with several channels. - */ -%% call(pt) filter_point_per_channel('Point', 'GP_FilterParam filter_callbacks[], GP_FilterParam priv[]', filter_op) -{{ filter_params(pt, 'filter_callbacks', 'func ', '_func', 'ptr') }} -{{ filter_params_raw(pt, 'priv', '_priv') }} -%% endcall - -/* - * Generated point filters for pixels with one channel. - */ -%% call(ps) filter_point_per_bpp('Point', 'GP_FilterParam filter_callbacks[], GP_FilterParam priv[]', filter_op) -{{ filter_param(ps, 'filter_callbacks', 'func ', '_func', 'ptr') }} -{{ filter_param_raw(ps, 'priv', '_priv') }} -%% endcall - -{{ filter_functions('Point', 'GP_FilterParam filter_callbacks[], GP_FilterParam priv[]', 'filter_callbacks, priv') }} - -%% endblock body
http://repo.or.cz/w/gfxprim.git/commit/acb23fffacdae415b778e2effdc506d8d3b8b...
commit acb23fffacdae415b778e2effdc506d8d3b8b420 Author: Cyril Hrubis metan@ucw.cz Date: Sat Nov 9 00:25:01 2013 +0100
filters: Rotate: Remove the _Raw variants from API.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt index 1e8b74b..8350180 100644 --- a/build/syms/Filters_symbols.txt +++ b/build/syms/Filters_symbols.txt @@ -121,15 +121,12 @@ GP_FilterResizeCubic
GP_FilterRotate180 GP_FilterRotate180Alloc -GP_FilterRotate180_Raw
GP_FilterRotate270 GP_FilterRotate270Alloc -GP_FilterRotate270_Raw
GP_FilterRotate90 GP_FilterRotate90Alloc -GP_FilterRotate90_Raw
GP_FilterSigmaEx GP_FilterSigmaExAlloc diff --git a/libs/filters/GP_MirrorH.gen.c.t b/libs/filters/GP_MirrorH.gen.c.t index 4194eab..e190c37 100644 --- a/libs/filters/GP_MirrorH.gen.c.t +++ b/libs/filters/GP_MirrorH.gen.c.t @@ -65,11 +65,46 @@ static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Context *src,
%% endfor
-int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) +static int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { GP_FN_RET_PER_BPP_CONTEXT(GP_MirrorH_Raw, src, src, dst, callback); return 1; }
+int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->w && src->h <= dst->h, + "Destination is not large enough"); + + if (GP_FilterMirrorH_Raw(src, dst, callback)) { + GP_DEBUG(1, "Operation aborted"); + return 1; + } + + return 0; +} + +GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, + GP_ProgressCallback *callback) +{ + GP_Context *res; + + res = GP_ContextCopy(src, 0); + + if (res == NULL) + return NULL; + + if (GP_FilterMirrorH_Raw(src, res, callback)) { + GP_ContextFree(res); + return NULL; + } + + return res; +} + + %% endblock body diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c index 5200b55..1b3f741 100644 --- a/libs/filters/GP_Rotate.c +++ b/libs/filters/GP_Rotate.c @@ -105,145 +105,6 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, return res; }
-int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) -{ - GP_ASSERT(src->pixel_type == dst->pixel_type, - "The src and dst pixel types must match"); - GP_ASSERT(src->w <= dst->w && src->h <= dst->h, - "Destination is not large enough"); - - if (GP_FilterMirrorH_Raw(src, dst, callback)) { - GP_DEBUG(1, "Operation aborted"); - return 1; - } - - return 0; -} - -GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, - GP_ProgressCallback *callback) -{ - GP_Context *res; - - res = GP_ContextCopy(src, 0); - - if (res == NULL) - return NULL; - - if (GP_FilterMirrorH_Raw(src, res, callback)) { - GP_ContextFree(res); - return NULL; - } - - return res; -} - -int GP_FilterRotate90(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) -{ - GP_ASSERT(src->pixel_type == dst->pixel_type, - "The src and dst pixel types must match"); - GP_ASSERT(src->w <= dst->h && src->h <= dst->w, - "Destination is not large enough"); - - if (GP_FilterRotate90_Raw(src, dst, callback)) { - GP_DEBUG(1, "Operation aborted"); - return 1; - } - - return 0; -} - -GP_Context *GP_FilterRotate90Alloc(const GP_Context *src, - GP_ProgressCallback *callback) -{ - GP_Context *res; - - res = GP_ContextAlloc(src->h, src->w, src->pixel_type); - - if (res == NULL) - return NULL; - - if (GP_FilterRotate90_Raw(src, res, callback)) { - GP_DEBUG(1, "Operation aborted"); - GP_ContextFree(res); - return NULL; - } - - return res; -} - -int GP_FilterRotate180(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) -{ - GP_ASSERT(src->pixel_type == dst->pixel_type, - "The src and dst pixel types must match"); - GP_ASSERT(src->w <= dst->w && src->h <= dst->h, - "Destination is not large enough"); - - if (GP_FilterRotate180_Raw(src, dst, callback)) { - GP_DEBUG(1, "Operation aborted"); - return 1; - } - - return 0; -} - -GP_Context *GP_FilterRotate180Alloc(const GP_Context *src, - GP_ProgressCallback *callback) -{ - GP_Context *res; - - res = GP_ContextCopy(src, 0); - - if (res == NULL) - return NULL; - - if (GP_FilterRotate180_Raw(src, res, callback)) { - GP_DEBUG(1, "Operation aborted"); - GP_ContextFree(res); - return NULL; - } - - return res; -} - -int GP_FilterRotate270(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) -{ - GP_ASSERT(src->pixel_type == dst->pixel_type, - "The src and dst pixel types must match"); - GP_ASSERT(src->w <= dst->h && src->h <= dst->w, - "Destination is not large enough"); - - if (GP_FilterRotate270_Raw(src, dst, callback)) { - GP_DEBUG(1, "Operation aborted"); - return 1; - } - - return 0; -} - -GP_Context *GP_FilterRotate270Alloc(const GP_Context *src, - GP_ProgressCallback *callback) -{ - GP_Context *res; - - res = GP_ContextAlloc(src->h, src->w, src->pixel_type); - - if (res == NULL) - return NULL; - - if (GP_FilterRotate270_Raw(src, res, callback)) { - GP_DEBUG(1, "Operation aborted"); - GP_ContextFree(res); - return NULL; - } - - return res; -} - static const char *symmetry_names[] = { "90", "180", diff --git a/libs/filters/GP_Rotate.gen.c.t b/libs/filters/GP_Rotate.gen.c.t index 364dd77..05c404c 100644 --- a/libs/filters/GP_Rotate.gen.c.t +++ b/libs/filters/GP_Rotate.gen.c.t @@ -54,13 +54,48 @@ static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Conte
%% endfor
-int GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) +static int GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate90_Raw, src, src, dst, callback); return 1; }
+int GP_FilterRotate90(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->h && src->h <= dst->w, + "Destination is not large enough"); + + if (GP_FilterRotate90_Raw(src, dst, callback)) { + GP_DEBUG(1, "Operation aborted"); + return 1; + } + + return 0; +} + +GP_Context *GP_FilterRotate90Alloc(const GP_Context *src, + GP_ProgressCallback *callback) +{ + GP_Context *res; + + res = GP_ContextAlloc(src->h, src->w, src->pixel_type); + + if (res == NULL) + return NULL; + + if (GP_FilterRotate90_Raw(src, res, callback)) { + GP_DEBUG(1, "Operation aborted"); + GP_ContextFree(res); + return NULL; + } + + return res; +} + %% macro swap_pixels(ps, src, dst, x0, y0, x1, y1) GP_Pixel pix0 = GP_GetPixel_Raw_{{ ps.suffix }}({{ src }}, {{ x0 }}, {{ y0 }}); GP_Pixel pix1 = GP_GetPixel_Raw_{{ ps.suffix }}({{ src }}, {{ x1 }}, {{ y1 }}); @@ -94,13 +129,48 @@ static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
%% endfor
-int GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) +static int GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate180_Raw, src, src, dst, callback); return 1; }
+int GP_FilterRotate180(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->w && src->h <= dst->h, + "Destination is not large enough"); + + if (GP_FilterRotate180_Raw(src, dst, callback)) { + GP_DEBUG(1, "Operation aborted"); + return 1; + } + + return 0; +} + +GP_Context *GP_FilterRotate180Alloc(const GP_Context *src, + GP_ProgressCallback *callback) +{ + GP_Context *res; + + res = GP_ContextCopy(src, 0); + + if (res == NULL) + return NULL; + + if (GP_FilterRotate180_Raw(src, res, callback)) { + GP_DEBUG(1, "Operation aborted"); + GP_ContextFree(res); + return NULL; + } + + return res; +} + %% for ps in pixelsizes static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) @@ -125,11 +195,46 @@ static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
%% endfor
-int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) +static int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate270_Raw, src, src, dst, callback); return 1; }
+int GP_FilterRotate270(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->h && src->h <= dst->w, + "Destination is not large enough"); + + if (GP_FilterRotate270_Raw(src, dst, callback)) { + GP_DEBUG(1, "Operation aborted"); + return 1; + } + + return 0; +} + +GP_Context *GP_FilterRotate270Alloc(const GP_Context *src, + GP_ProgressCallback *callback) +{ + GP_Context *res; + + res = GP_ContextAlloc(src->h, src->w, src->pixel_type); + + if (res == NULL) + return NULL; + + if (GP_FilterRotate270_Raw(src, res, callback)) { + GP_DEBUG(1, "Operation aborted"); + GP_ContextFree(res); + return NULL; + } + + return res; +} + %% endblock body
http://repo.or.cz/w/gfxprim.git/commit/280e32f1a1d6f25018f19a0a793f470144650...
commit 280e32f1a1d6f25018f19a0a793f470144650eef Author: Cyril Hrubis metan@ucw.cz Date: Sat Nov 9 00:15:01 2013 +0100
filters: Rotate: Remove _Raw prototypes from header.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h index 356ceb1..f156068 100644 --- a/include/filters/GP_Rotate.h +++ b/include/filters/GP_Rotate.h @@ -33,16 +33,6 @@ #include "GP_Filter.h"
/* - * Mirror horizontally. - * - * Works 'in place'. The contexts must have equal pixel_type and size. - * - * This is semi-internal function without any assertions on destination. - */ -int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback); - -/* * Mirrors bitmap horizontally. * * The dst must be at least as big as source. @@ -66,16 +56,6 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, GP_ProgressCallback *callback);
/* - * Mirror vertically - * - * Works 'in place'. The contexts must have equal pixel_type and size. - * - * This is semi-internal function without any assertions on destination. - */ -int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback); - -/* * Mirrors bitmap vertically. * * The dst must be at least as big as source. @@ -99,23 +79,6 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, GP_ProgressCallback *callback);
/* - * Rotate context by 90, 180 and 270. - * - * Doesn't work 'in place'. The contexts must have equal pixel_type size must - * match the rotated size (is equal for 180 and swapped for 90 and 270). - * - * These are semi-internal functions without any assertions on destination. - */ -int GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback); - -int GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback); - -int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback); - -/* * Rotate the context by 90, 180, 270. * * Returns pointer to destination bitmap or NULL if allocation failed.
http://repo.or.cz/w/gfxprim.git/commit/6a4ef1c559652d3f2e1d7c1e69d47f214364a...
commit 6a4ef1c559652d3f2e1d7c1e69d47f214364a9d6 Author: Cyril Hrubis metan@ucw.cz Date: Sat Nov 9 00:13:34 2013 +0100
filters: Swap GP_MirrorH() and GP_MirrorV()
I've got it wrong when I was implementing them...
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/filters/GP_MirrorV.gen.c.t b/libs/filters/GP_MirrorH.gen.c.t similarity index 89% rename from libs/filters/GP_MirrorV.gen.c.t rename to libs/filters/GP_MirrorH.gen.c.t index 99599af..4194eab 100644 --- a/libs/filters/GP_MirrorV.gen.c.t +++ b/libs/filters/GP_MirrorH.gen.c.t @@ -22,7 +22,7 @@
%% extends "base.c.t"
-{% block descr %}Vertical Mirror alogorithm{% endblock %} +{% block descr %}Horizontal Mirror alogorithm{% endblock %}
%% block body
@@ -31,14 +31,14 @@ #include "GP_Rotate.h"
%% for ps in pixelsizes -static int GP_MirrorV_Raw_{{ ps.suffix }}(const GP_Context *src, +static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) { uint32_t x, y; GP_Pixel tmp;
- GP_DEBUG(1, "Mirroring image vertically %ux%u", src->w, src->h); + GP_DEBUG(1, "Mirroring image %ux%u horizontally", src->w, src->h);
for (x = 0; x < src->w/2; x++) { uint32_t xm = src->w - x - 1; @@ -65,10 +65,10 @@ static int GP_MirrorV_Raw_{{ ps.suffix }}(const GP_Context *src,
%% endfor
-int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) { - GP_FN_RET_PER_BPP_CONTEXT(GP_MirrorV_Raw, src, src, dst, callback); + GP_FN_RET_PER_BPP_CONTEXT(GP_MirrorH_Raw, src, src, dst, callback); return 1; }
diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c index 0e53645..5200b55 100644 --- a/libs/filters/GP_Rotate.c +++ b/libs/filters/GP_Rotate.c @@ -29,14 +29,14 @@
#include <string.h>
-int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) { uint32_t bpr = src->bytes_per_row; uint8_t buf[bpr]; unsigned int y;
- GP_DEBUG(1, "Mirroring image horizontally %ux%u", src->w, src->h); + GP_DEBUG(1, "Mirroring image %ux%u vertically", src->w, src->h);
#warning FIXME: non byte aligned pixels
@@ -72,7 +72,7 @@ int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, return 0; }
-int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) { GP_ASSERT(src->pixel_type == dst->pixel_type, @@ -81,13 +81,13 @@ int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, GP_ASSERT(src->w <= dst->w && src->h <= dst->h, "Destination is not large enough");
- if (GP_FilterMirrorH_Raw(src, dst, callback)) + if (GP_FilterMirrorV_Raw(src, dst, callback)) return 1;
return 0; }
-GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, +GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, GP_ProgressCallback *callback) { GP_Context *res; @@ -97,7 +97,7 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, if (res == NULL) return NULL;
- if (GP_FilterMirrorH_Raw(src, res, callback)) { + if (GP_FilterMirrorV_Raw(src, res, callback)) { GP_ContextFree(res); return NULL; } @@ -105,7 +105,7 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, return res; }
-int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) { GP_ASSERT(src->pixel_type == dst->pixel_type, @@ -113,7 +113,7 @@ int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, GP_ASSERT(src->w <= dst->w && src->h <= dst->h, "Destination is not large enough");
- if (GP_FilterMirrorV_Raw(src, dst, callback)) { + if (GP_FilterMirrorH_Raw(src, dst, callback)) { GP_DEBUG(1, "Operation aborted"); return 1; } @@ -121,7 +121,7 @@ int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, return 0; }
-GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, +GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, GP_ProgressCallback *callback) { GP_Context *res; @@ -131,7 +131,7 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, if (res == NULL) return NULL;
- if (GP_FilterMirrorV_Raw(src, res, callback)) { + if (GP_FilterMirrorH_Raw(src, res, callback)) { GP_ContextFree(res); return NULL; } diff --git a/libs/filters/Makefile b/libs/filters/Makefile index c929aa7..d1a909c 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -13,7 +13,7 @@ ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c RESAMPLING_FILTERS=GP_ResizeNN.gen.c GP_Cubic.gen.c GP_ResizeCubic.gen.c GP_ResizeLinear.gen.c
-GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_FloydSteinberg.gen.c GP_HilbertPeano.gen.c+GENSOURCES=GP_MirrorH.gen.c GP_Rotate.gen.c GP_FloydSteinberg.gen.c GP_HilbertPeano.gen.c $(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS) $(RESAMPLING_FILTERS) GP_LinearConvolution.gen.c
http://repo.or.cz/w/gfxprim.git/commit/445b1c8edfd8a95ad0f40e13f20eade2f6fbe...
commit 445b1c8edfd8a95ad0f40e13f20eade2f6fbed10 Author: Cyril Hrubis metan@ucw.cz Date: Sat Nov 9 00:03:40 2013 +0100
filters: GP_Rotate.c: Fix whitespaces.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c index 6aff0ba..0e53645 100644 --- a/libs/filters/GP_Rotate.c +++ b/libs/filters/GP_Rotate.c @@ -125,9 +125,9 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, GP_ProgressCallback *callback) { GP_Context *res; - + res = GP_ContextCopy(src, 0); - + if (res == NULL) return NULL;
@@ -135,7 +135,7 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, GP_ContextFree(res); return NULL; } - + return res; }
@@ -159,9 +159,9 @@ GP_Context *GP_FilterRotate90Alloc(const GP_Context *src, GP_ProgressCallback *callback) { GP_Context *res; - + res = GP_ContextAlloc(src->h, src->w, src->pixel_type); - + if (res == NULL) return NULL;
@@ -194,9 +194,9 @@ GP_Context *GP_FilterRotate180Alloc(const GP_Context *src, GP_ProgressCallback *callback) { GP_Context *res; - + res = GP_ContextCopy(src, 0); - + if (res == NULL) return NULL;
@@ -229,9 +229,9 @@ GP_Context *GP_FilterRotate270Alloc(const GP_Context *src, GP_ProgressCallback *callback) { GP_Context *res; - + res = GP_ContextAlloc(src->h, src->w, src->pixel_type); - + if (res == NULL) return NULL;
http://repo.or.cz/w/gfxprim.git/commit/ef943c2310c1345dbc8bd34c3cdd26648ed79...
commit ef943c2310c1345dbc8bd34c3cdd26648ed79420 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 8 23:41:15 2013 +0100
doc: Update/Add point filters docs.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/filters.txt b/doc/filters.txt index ed39486..93a2888 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -54,204 +54,116 @@ GP_Context *GP_FilterFooAlloc(const GP_Context *src, -------------------------------------------------------------------------------
-Filters also exists in _Raw variant whose interface is similar to the first -type of filter function. These filter APIs are used for internal -implementation and shouldn't be called by user as the destination is expected -to be crafted exactly for storing the filter result and there are 'NO' sanity -checks in place. +Point Filters +~~~~~~~~~~~~~
-'You could use these at your own risk' - -[source,c] -------------------------------------------------------------------------------- -/* - * Raw filter common API. - */ -int GP_FilterFoo_Raw(const GP_Context *src, GP_Context *dst, - foo params ..., - GP_ProgressCallback *callback); -------------------------------------------------------------------------------- - -Filter Parameters -~~~~~~~~~~~~~~~~~ +Point operations are filters that works with pixels as with independent values +(the value of destination pixel depends only on the pixel on the same +coordinates in source image). All of these filters works 'in-place' and the +result has always the same size as the source.
-In order to pass, per-channel, filter parameters to a filter, structure called -GP_FilterParams was created. +Invert +^^^^^^
[source,c] ------------------------------------------------------------------------------- #include <GP.h> /* or */ -#include <filters/GP_FilterParam.h> +#include <filters/GP_Point.h>
-typedef union GP_FilterParamVal { - float f; - uint32_t ui; - int32_t i; - void *ptr; -} GP_FilterParamVal; +int GP_FilterInvert(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback);
-typedef struct GP_FilterParam { - char channel_name[2]; - union GP_FilterParamVal val; -} GP_FilterParam; +GP_Context *GP_FilterInvertAlloc(const GP_Context *src, + GP_ProgressCallback *callback); -------------------------------------------------------------------------------
-Some filters do take an empty channel_name terminated (empty channel_name is -empty string i.e. "0") array of GP_FilterParam, which is used to describe -per-channel parameters. +The pixel channel values are counted as +chann_max - val+.
+include::images/invert/images.txt[]
-There are two methods how to construct GP_FilterParam structure. First one is -to use macro that expands to a code which declares and initializes the array on -the stack second uses memory allocated by a malloc(). In both cases the -structure is has initialized channel names and terminator. +Brightness +^^^^^^^^^^
[source,c] ------------------------------------------------------------------------------- #include <GP.h> /* or */ -#include <filters/GP_FilterParam.h> - -#define GP_FILTER_PARAMS(pixel_type, name) - GP_FilterParam name[GP_PixelTypes[pixel_type].numchannels + 1]; - GP_FilterParamInitChannels(name, pixel_type); -------------------------------------------------------------------------------- +#include <filters/GP_Point.h>
-Macro that declares and initializes GP_FilterParam structure for a given -pixel_type. +int GP_FilterBrightness(const GP_Context *src, GP_Context *dst, + float p, GP_ProgressCallback *callback);
-[source,c] +GP_Context *GP_FilterBrightnessAlloc(const GP_Context *src, float p, + GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -#include <GP.h> -/* or */ -#include <filters/GP_FilterParam.h>
-GP_FilterParam *GP_FilterParamCreate(GP_PixelType pixel_type); +The pixel channel values are counted as +val + chann_max * p+.
-void GP_FilterParamDestroy(GP_FilterParam *self); -------------------------------------------------------------------------------- +include::images/brightness/images.txt[]
-Second possible way allocates memory using malloc(). - -Functions for manipulating and querying existing GP_FilterParam follows. +Contrast +^^^^^^^^
[source,c] ------------------------------------------------------------------------------- #include <GP.h> /* or */ -#include <filters/GP_FilterParam.h> - -void GP_FilterParamInitChannels(GP_FilterParam params[], - GP_PixelType pixel_type); -------------------------------------------------------------------------------- +#include <filters/GP_Point.h>
-Initializes filter param array channel names (accordingly to pixel type) and -terminator. The params array must be large enough to hold number of pixel type -channels plus one. +int GP_FilterContrast(const GP_Context *src, GP_Context *dst, + float p, GP_ProgressCallback *callback);
-[source,c] -------------------------------------------------------------------------------- -#include <GP.h> -/* or */ -#include <filters/GP_FilterParam.h> - -GP_FilterParam *GP_FilterParamChannel(GP_FilterParam params[], - const char *channel_name); +GP_Context *GP_FilterContrastAlloc(const GP_Context *src, float p, + GP_ProgressCallback *callback); -------------------------------------------------------------------------------
-Does lookup for a given channel name and returns, if found, corresponding -GP_FilterParam, otherwise 'NULL' is returned. - -This function is primary used in filters, where filter, at the start, resolves -all it's parameters. - -[source,c] -------------------------------------------------------------------------------- -#include <GP.h> -/* or */ -#include <filters/GP_FilterParam.h> +The pixel channel values are counted as +val * p+.
-int GP_FilterParamCheckPixelType(GP_FilterParam params[], - GP_PixelType pixel_type); -------------------------------------------------------------------------------- +include::images/contrast/images.txt[]
-Matches param structure against pixel_type. Returns zero if params describes -exactly same channels like pixel_type, non-zero otherwise. +BrightnessContrast +^^^^^^^^^^^^^^^^^^
[source,c] ------------------------------------------------------------------------------- #include <GP.h> /* or */ -#include <filters/GP_FilterParam.h> - -void GP_FilterParamSetIntAll(GP_FilterParam params[], int32_t val); - -int GP_FilterParamSetInt(GP_FilterParam params[], const char *channel_name, - int32_t val); - -void GP_FilterParamSetFloatAll(GP_FilterParam params[], float val); - -int GP_FilterParamSetFloat(GP_FilterParam params[], const char *channel_name, - float val); - -void GP_FilterParamSetUIntAll(GP_FilterParam params[], uint32_t val); +#include <filters/GP_Point.h>
-int GP_FilterParamSetUInt(GP_FilterParam params[], const char *channel_name, - uint32_t val); - -void GP_FilterParamSetPtrAll(GP_FilterParam params[], void *ptr); - -int GP_FilterParamSetPtr(GP_FilterParam params[], const char *channel_name, - void *ptr); +int GP_FilterBrightnessContrast(const GP_Context *src, GP_Context *dst, + float b, float c, + GP_ProgressCallback *callback);
-void GP_FilterParamFreePtrAll(GP_FilterParam params[]); +GP_Context *GP_FilterBrightnessContrastAlloc(const GP_Context *src, + float b, float c, + GP_ProgressCallback *callback); -------------------------------------------------------------------------------
-Parameter setters. Those that sets individual value returns zero on success -(i.e. channel was found) and non-zero otherwise. +The pixel channel values are counted as +val * c + chann_max * b+.
-The last one calls free() on all param pointers, which is used to free -allocate memory. +include::images/brightness_contrast/images.txt[]
-Point operation filters -~~~~~~~~~~~~~~~~~~~~~~~ - -Point operations are filters that works with pixels as with independent values -(the value of destination pixel depends only on the pixel on the same -coordinates in source image). All of these filters works 'in-place' and the -result has always the same size as the source. +Posterize +^^^^^^^^^
[source,c] ------------------------------------------------------------------------------- -#include <GP_Filters.h> - -GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst, - int32_t inc, GP_ProgressCallback *callback); -------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_Point.h>
-Brightness filter, increments all pixel channels by a fixed value. +int GP_FilterPosterize(const GP_Context *src, GP_Context *dst, + unsigned int levels, GP_ProgressCallback *callback);
-[source,c] -------------------------------------------------------------------------------- -#include <GP_Filters.h> - -GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst, - float mul, GP_ProgressCallback *callback); +GP_Context *GP_FilterPosterizeAlloc(const GP_Context *src, unsigned int levels, + GP_ProgressCallback *callback); -------------------------------------------------------------------------------
-Contrast filter, multiplies all pixel channels by a fixed value. - -[source,c] -------------------------------------------------------------------------------- -#include <GP_Filters.h> +The pixel channel values are quantized into number of levels.
-GP_Context *GP_FilterInvert(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback); -------------------------------------------------------------------------------- +include::images/posterize/images.txt[]
-Inverts the image, for each channel the result value is computed as "chan_max -- val".
Gaussian additive noise filter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/filters_python.txt b/doc/filters_python.txt index db7eb9d..6802510 100644 --- a/doc/filters_python.txt +++ b/doc/filters_python.txt @@ -11,6 +11,109 @@ image is passed automatically as a first parameter. If filter has been aborted from callback 'OSError' with 'errno' set to 'ECANCELED' is raised.
+Point Filters +~~~~~~~~~~~~~ + +Invert +^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Inverts image in-place + img.filters.Invert(img, callback=None) + + # Returns newly allocated inverted image + res = img.filters.InvertAlloc(callback=None) + +------------------------------------------------------------------------------- + +The pixel channel values are counted as +chann_max - val+. + +include::images/invert/images.txt[] + +Brightness +^^^^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Increses images brightness in-place by channel_max * 0.2 + img.filters.Brightness(img, 0.2, callback=None) + + # Returns image with brightness decreased by channel_max * -0.5 + res = img.filters.BrightnessAlloc(img, -0.5, callback=None) + +------------------------------------------------------------------------------- + +The pixel channel values are counted as +val + chann_max * p+. + +include::images/brightness/images.txt[] + +Contrast +^^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Increses images contrast by 1.2 + img.filters.Contrast(img, 1.2, callback=None) + + # Returns image with contrast decreased by 0.2 + res = img.filters.ContrastAlloc(img, 0.2, callback=None) + +------------------------------------------------------------------------------- + +The pixel channel values are counted as +val * p+. + +include::images/contrast/images.txt[] + +BrightnessContrast +^^^^^^^^^^^^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Increses images contrast by 1.2 decreases brightness by -0.2 + img.filters.BrightnessContrast(img, -0.2, 1.2, callback=None) + + # Returns image with contrast decreased by 0.2 brightness increased by .5 + res = img.filters.BrightnessContrastAlloc(img, 0.5, 0.2, callback=None) + +------------------------------------------------------------------------------- + +The pixel channel values are counted as +val * c + chann_max * b+. + +include::images/brightness_contrast/images.txt[] + +Posterize +^^^^^^^^^ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Posterizes image using 2 steps + img.filters.Posterize(img, 2, callback=None) + + # Returns image posterized into 4 levels + res = img.filters.PosterizeAlloc(img, 4, callback=None) + +------------------------------------------------------------------------------- + +The pixel channel values are quantized into number of levels. + +include::images/posterize/images.txt[] + Gaussian Additive Noise ~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/images/brightness/images.txt b/doc/images/brightness/images.txt new file mode 100644 index 0000000..37836f4 --- /dev/null +++ b/doc/images/brightness/images.txt @@ -0,0 +1,17 @@ +.Original Image; Brightness p=-0.5, p=-0.2, p=0.2, p=0.5 +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/brightness/lenna_small_-0.5.png[ + "Brightness -0.5", + link="images/brightness/lenna_-0.5.png"] +image:images/brightness/lenna_small_-0.2.png[ + "Brightness -0.2", + link="images/brightness/lenna_-0.2.png"] +image:images/brightness/lenna_small_0.2.png[ + "Brightness 0.2", + link="images/brightness/lenna_0.2.png"] +image:images/brightness/lenna_small_0.5.png[ + "Brightness 0.5", + link="images/brightness/lenna_0.5.png"] + diff --git a/doc/images/brightness/lenna_-0.2.png b/doc/images/brightness/lenna_-0.2.png new file mode 100644 index 0000000..dd6c2ab Binary files /dev/null and b/doc/images/brightness/lenna_-0.2.png differ diff --git a/doc/images/brightness/lenna_-0.5.png b/doc/images/brightness/lenna_-0.5.png new file mode 100644 index 0000000..4305294 Binary files /dev/null and b/doc/images/brightness/lenna_-0.5.png differ diff --git a/doc/images/brightness/lenna_0.2.png b/doc/images/brightness/lenna_0.2.png new file mode 100644 index 0000000..35b17ab Binary files /dev/null and b/doc/images/brightness/lenna_0.2.png differ diff --git a/doc/images/brightness/lenna_0.5.png b/doc/images/brightness/lenna_0.5.png new file mode 100644 index 0000000..a2e305f Binary files /dev/null and b/doc/images/brightness/lenna_0.5.png differ diff --git a/doc/images/brightness/lenna_small_-0.2.png b/doc/images/brightness/lenna_small_-0.2.png new file mode 100644 index 0000000..5d45c63 Binary files /dev/null and b/doc/images/brightness/lenna_small_-0.2.png differ diff --git a/doc/images/brightness/lenna_small_-0.5.png b/doc/images/brightness/lenna_small_-0.5.png new file mode 100644 index 0000000..11e02c8 Binary files /dev/null and b/doc/images/brightness/lenna_small_-0.5.png differ diff --git a/doc/images/brightness/lenna_small_0.2.png b/doc/images/brightness/lenna_small_0.2.png new file mode 100644 index 0000000..dea074e Binary files /dev/null and b/doc/images/brightness/lenna_small_0.2.png differ diff --git a/doc/images/brightness/lenna_small_0.5.png b/doc/images/brightness/lenna_small_0.5.png new file mode 100644 index 0000000..d63e922 Binary files /dev/null and b/doc/images/brightness/lenna_small_0.5.png differ diff --git a/doc/images/brightness_contrast/images.txt b/doc/images/brightness_contrast/images.txt new file mode 100644 index 0000000..85812c3 --- /dev/null +++ b/doc/images/brightness_contrast/images.txt @@ -0,0 +1,17 @@ +.Original Image; BrightnessContrast b=-0.2 c=0.8, b=-0.5 c=2, b=0.2 c=0.8, b=0.2 c=1.5 +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/brightness_contrast/lenna_small_-0.2_0.8.png[ + "BrightnessContrast -0.2 0.8", + link="images/brightness_contrast/lenna_-0.2_0.8.png"] +image:images/brightness_contrast/lenna_small_-0.5_2.png[ + "BrightnessContrast -0.5 2", + link="images/brightness_contrast/lenna_-0.5_2.png"] +image:images/brightness_contrast/lenna_small_0.2_0.8.png[ + "BrightnessContrast 0.2 0.8", + link="images/brightness_contrast/lenna_0.2_0.8.png"] +image:images/brightness_contrast/lenna_small_0.2_1.5.png[ + "BrightnessContrast 0.2 1.5", + link="images/brightness_contrast/lenna_0.2_1.5.png"] + diff --git a/doc/images/brightness_contrast/lenna_-0.2_0.8.png b/doc/images/brightness_contrast/lenna_-0.2_0.8.png new file mode 100644 index 0000000..698eba9 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_-0.2_0.8.png differ diff --git a/doc/images/brightness_contrast/lenna_-0.5_2.png b/doc/images/brightness_contrast/lenna_-0.5_2.png new file mode 100644 index 0000000..267c873 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_-0.5_2.png differ diff --git a/doc/images/brightness_contrast/lenna_0.2_0.5.png b/doc/images/brightness_contrast/lenna_0.2_0.5.png new file mode 100644 index 0000000..611122d Binary files /dev/null and b/doc/images/brightness_contrast/lenna_0.2_0.5.png differ diff --git a/doc/images/brightness_contrast/lenna_0.2_0.8.png b/doc/images/brightness_contrast/lenna_0.2_0.8.png new file mode 100644 index 0000000..465a3c4 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_0.2_0.8.png differ diff --git a/doc/images/brightness_contrast/lenna_0.2_1.5.png b/doc/images/brightness_contrast/lenna_0.2_1.5.png new file mode 100644 index 0000000..36c6a54 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_0.2_1.5.png differ diff --git a/doc/images/brightness_contrast/lenna_0.4_0.5.png b/doc/images/brightness_contrast/lenna_0.4_0.5.png new file mode 100644 index 0000000..68cb7b1 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_0.4_0.5.png differ diff --git a/doc/images/brightness_contrast/lenna_small_-0.2_0.8.png b/doc/images/brightness_contrast/lenna_small_-0.2_0.8.png new file mode 100644 index 0000000..20ff951 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_-0.2_0.8.png differ diff --git a/doc/images/brightness_contrast/lenna_small_-0.5_2.png b/doc/images/brightness_contrast/lenna_small_-0.5_2.png new file mode 100644 index 0000000..7ccab22 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_-0.5_2.png differ diff --git a/doc/images/brightness_contrast/lenna_small_0.2_0.5.png b/doc/images/brightness_contrast/lenna_small_0.2_0.5.png new file mode 100644 index 0000000..6752bfb Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_0.2_0.5.png differ diff --git a/doc/images/brightness_contrast/lenna_small_0.2_0.8.png b/doc/images/brightness_contrast/lenna_small_0.2_0.8.png new file mode 100644 index 0000000..a4747b9 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_0.2_0.8.png differ diff --git a/doc/images/brightness_contrast/lenna_small_0.2_1.5.png b/doc/images/brightness_contrast/lenna_small_0.2_1.5.png new file mode 100644 index 0000000..d177b75 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_0.2_1.5.png differ diff --git a/doc/images/brightness_contrast/lenna_small_0.4_0.5.png b/doc/images/brightness_contrast/lenna_small_0.4_0.5.png new file mode 100644 index 0000000..b6af555 Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_0.4_0.5.png differ diff --git a/doc/images/contrast/images.txt b/doc/images/contrast/images.txt new file mode 100644 index 0000000..b4533f6 --- /dev/null +++ b/doc/images/contrast/images.txt @@ -0,0 +1,20 @@ +.Original Image; Contrast p=0.2, p=0.5, p=1.5, p=2, p=3 +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/contrast/lenna_small_0.2.png[ + "Contrast 0.2", + link="images/contrast/lenna_0.2.png"] +image:images/contrast/lenna_small_0.5.png[ + "Contrast 0.5", + link="images/contrast/lenna_0.5.png"] +image:images/contrast/lenna_small_1.5.png[ + "Contrast 1.5", + link="images/contrast/lenna_1.5.png"] +image:images/contrast/lenna_small_2.png[ + "Contrast 2", + link="images/contrast/lenna_2.png"] +image:images/contrast/lenna_small_3.png[ + "Contrast 3", + link="images/contrast/lenna_3.png"] + diff --git a/doc/images/contrast/lenna_0.1.png b/doc/images/contrast/lenna_0.1.png new file mode 100644 index 0000000..9f20010 Binary files /dev/null and b/doc/images/contrast/lenna_0.1.png differ diff --git a/doc/images/contrast/lenna_0.2.png b/doc/images/contrast/lenna_0.2.png new file mode 100644 index 0000000..457aeed Binary files /dev/null and b/doc/images/contrast/lenna_0.2.png differ diff --git a/doc/images/contrast/lenna_0.5.png b/doc/images/contrast/lenna_0.5.png new file mode 100644 index 0000000..1b9c60d Binary files /dev/null and b/doc/images/contrast/lenna_0.5.png differ diff --git a/doc/images/contrast/lenna_1.5.png b/doc/images/contrast/lenna_1.5.png new file mode 100644 index 0000000..26c8300 Binary files /dev/null and b/doc/images/contrast/lenna_1.5.png differ diff --git a/doc/images/contrast/lenna_2.png b/doc/images/contrast/lenna_2.png new file mode 100644 index 0000000..3940472 Binary files /dev/null and b/doc/images/contrast/lenna_2.png differ diff --git a/doc/images/contrast/lenna_3.png b/doc/images/contrast/lenna_3.png new file mode 100644 index 0000000..56318c0 Binary files /dev/null and b/doc/images/contrast/lenna_3.png differ diff --git a/doc/images/contrast/lenna_4.png b/doc/images/contrast/lenna_4.png new file mode 100644 index 0000000..ca033c8 Binary files /dev/null and b/doc/images/contrast/lenna_4.png differ diff --git a/doc/images/contrast/lenna_small_0.1.png b/doc/images/contrast/lenna_small_0.1.png new file mode 100644 index 0000000..529a120 Binary files /dev/null and b/doc/images/contrast/lenna_small_0.1.png differ diff --git a/doc/images/contrast/lenna_small_0.2.png b/doc/images/contrast/lenna_small_0.2.png new file mode 100644 index 0000000..4ad19f3 Binary files /dev/null and b/doc/images/contrast/lenna_small_0.2.png differ diff --git a/doc/images/contrast/lenna_small_0.5.png b/doc/images/contrast/lenna_small_0.5.png new file mode 100644 index 0000000..f96b6d3 Binary files /dev/null and b/doc/images/contrast/lenna_small_0.5.png differ diff --git a/doc/images/contrast/lenna_small_1.5.png b/doc/images/contrast/lenna_small_1.5.png new file mode 100644 index 0000000..a4ed2c5 Binary files /dev/null and b/doc/images/contrast/lenna_small_1.5.png differ diff --git a/doc/images/contrast/lenna_small_2.png b/doc/images/contrast/lenna_small_2.png new file mode 100644 index 0000000..ef2a128 Binary files /dev/null and b/doc/images/contrast/lenna_small_2.png differ diff --git a/doc/images/contrast/lenna_small_3.png b/doc/images/contrast/lenna_small_3.png new file mode 100644 index 0000000..4fae79c Binary files /dev/null and b/doc/images/contrast/lenna_small_3.png differ diff --git a/doc/images/contrast/lenna_small_4.png b/doc/images/contrast/lenna_small_4.png new file mode 100644 index 0000000..c8537e4 Binary files /dev/null and b/doc/images/contrast/lenna_small_4.png differ diff --git a/doc/images/invert/images.txt b/doc/images/invert/images.txt new file mode 100644 index 0000000..7a3e952 --- /dev/null +++ b/doc/images/invert/images.txt @@ -0,0 +1,8 @@ +.Original Image; Inverted +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/invert/lenna_small_.png[ + "Inverted ", + link="images/invert/lenna_.png"] + diff --git a/doc/images/invert/lenna_.png b/doc/images/invert/lenna_.png new file mode 100644 index 0000000..2909167 Binary files /dev/null and b/doc/images/invert/lenna_.png differ diff --git a/doc/images/invert/lenna_small_.png b/doc/images/invert/lenna_small_.png new file mode 100644 index 0000000..cd32e36 Binary files /dev/null and b/doc/images/invert/lenna_small_.png differ diff --git a/doc/images/posterize/images.txt b/doc/images/posterize/images.txt new file mode 100644 index 0000000..9a5ee63 --- /dev/null +++ b/doc/images/posterize/images.txt @@ -0,0 +1,20 @@ +.Original Image; Posterize s=2, s=3, s=4, s=5, s=6 +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/posterize/lenna_small_2.png[ + "Posterize 2", + link="images/posterize/lenna_2.png"] +image:images/posterize/lenna_small_3.png[ + "Posterize 3", + link="images/posterize/lenna_3.png"] +image:images/posterize/lenna_small_4.png[ + "Posterize 4", + link="images/posterize/lenna_4.png"] +image:images/posterize/lenna_small_5.png[ + "Posterize 5", + link="images/posterize/lenna_5.png"] +image:images/posterize/lenna_small_6.png[ + "Posterize 6", + link="images/posterize/lenna_6.png"] + diff --git a/doc/images/posterize/lenna_2.png b/doc/images/posterize/lenna_2.png new file mode 100644 index 0000000..a719aa3 Binary files /dev/null and b/doc/images/posterize/lenna_2.png differ diff --git a/doc/images/posterize/lenna_3.png b/doc/images/posterize/lenna_3.png new file mode 100644 index 0000000..83315c2 Binary files /dev/null and b/doc/images/posterize/lenna_3.png differ diff --git a/doc/images/posterize/lenna_4.png b/doc/images/posterize/lenna_4.png new file mode 100644 index 0000000..352efe1 Binary files /dev/null and b/doc/images/posterize/lenna_4.png differ diff --git a/doc/images/posterize/lenna_5.png b/doc/images/posterize/lenna_5.png new file mode 100644 index 0000000..d395005 Binary files /dev/null and b/doc/images/posterize/lenna_5.png differ diff --git a/doc/images/posterize/lenna_6.png b/doc/images/posterize/lenna_6.png new file mode 100644 index 0000000..ea8295c Binary files /dev/null and b/doc/images/posterize/lenna_6.png differ diff --git a/doc/images/posterize/lenna_small_2.png b/doc/images/posterize/lenna_small_2.png new file mode 100644 index 0000000..695fd16 Binary files /dev/null and b/doc/images/posterize/lenna_small_2.png differ diff --git a/doc/images/posterize/lenna_small_3.png b/doc/images/posterize/lenna_small_3.png new file mode 100644 index 0000000..c0b8252 Binary files /dev/null and b/doc/images/posterize/lenna_small_3.png differ diff --git a/doc/images/posterize/lenna_small_4.png b/doc/images/posterize/lenna_small_4.png new file mode 100644 index 0000000..f509351 Binary files /dev/null and b/doc/images/posterize/lenna_small_4.png differ diff --git a/doc/images/posterize/lenna_small_5.png b/doc/images/posterize/lenna_small_5.png new file mode 100644 index 0000000..ed1e80f Binary files /dev/null and b/doc/images/posterize/lenna_small_5.png differ diff --git a/doc/images/posterize/lenna_small_6.png b/doc/images/posterize/lenna_small_6.png new file mode 100644 index 0000000..cb1c8cc Binary files /dev/null and b/doc/images/posterize/lenna_small_6.png differ diff --git a/doc/images/regen.py b/doc/images/regen.py index 8a705f7..ace7e6a 100755 --- a/doc/images/regen.py +++ b/doc/images/regen.py @@ -61,6 +61,26 @@ class ImgGen: def main(): imggen = ImgGen('images/orig/')
+ imggen.gen(filters.InvertAlloc, [], + [[]], + 'images/invert/', 'Inverted') + + imggen.gen(filters.BrightnessAlloc, ['p'], + [[-.5], [-.2], [.2], [.5]], + 'images/brightness/', 'Brightness') + + imggen.gen(filters.ContrastAlloc, ['p'], + [[.2], [.5], [1.5], [2], [3]], + 'images/contrast/', 'Contrast') + + imggen.gen(filters.BrightnessContrastAlloc, ['b', 'c'], + [[-.2, .8], [-.5, 2], [.2, .8], [.2, 1.5]], + 'images/brightness_contrast/', 'BrightnessContrast') + + imggen.gen(filters.PosterizeAlloc, ['s'], + [[2], [3], [4], [5], [6]], + 'images/posterize/', 'Posterize') + imggen.gen(filters.GaussianBlurAlloc, ['xsig', 'ysig'], [[2, 2], [0, 4], [4, 0], [4, 4], [10, 10]], 'images/blur/', 'Gaussian Blur')
http://repo.or.cz/w/gfxprim.git/commit/6a0865b80f90e2397d90d13e836b0db3f8aaa...
commit 6a0865b80f90e2397d90d13e836b0db3f8aaa372 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 8 22:45:49 2013 +0100
filters: Add two point filters.
Add combined Brightness Contrast filter and Posterize filter.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h index e5c7e99..6ebf48c 100644 --- a/include/filters/GP_Point.h +++ b/include/filters/GP_Point.h @@ -50,9 +50,9 @@ static inline int GP_FilterBrightness(const GP_Context *src, GP_Context *dst, return GP_FilterBrightnessEx(&area, p, callback); }
-static inline GP_Context *GP_FilterBrightnessAlloc(const GP_Context *src, - float p, - GP_ProgressCallback *callback) +static inline GP_Context * +GP_FilterBrightnessAlloc(const GP_Context *src, float p, + GP_ProgressCallback *callback) { GP_FILTER_AREA_DEFAULT(src, NULL);
@@ -91,6 +91,65 @@ static inline GP_Context *GP_FilterContrastAlloc(const GP_Context *src, }
/* + * Brightness and Contrast combined. + */ +int GP_FilterBrightnessContrastEx(const GP_FilterArea *area, float b, float c, + GP_ProgressCallback *callback); + +GP_Context *GP_FilterBrightnessContrastExAlloc(const GP_FilterArea *area, + float b, float c, + GP_ProgressCallback *callback); + +static inline int +GP_FilterBrightnessContrast(const GP_Context *src, GP_Context *dst, + float b, float c, GP_ProgressCallback *callback) +{ + GP_FILTER_AREA_DEFAULT(src, dst); + + return GP_FilterBrightnessContrastEx(&area, b, c, callback); +} + +static inline GP_Context * +GP_FilterBrightnessContrastAlloc(const GP_Context *src, + float b, float c, + GP_ProgressCallback *callback) +{ + GP_FILTER_AREA_DEFAULT(src, NULL); + + return GP_FilterBrightnessContrastExAlloc(&area, b, c, callback); +} + +/* + * Posterize + * + * Does quantization into steps regions. + */ +int GP_FilterPosterizeEx(const GP_FilterArea *area, unsigned int steps, + GP_ProgressCallback *callback); + +GP_Context *GP_FilterPosterizeExAlloc(const GP_FilterArea *area, + unsigned int steps, + GP_ProgressCallback *callback); + +static inline int GP_FilterPosterize(const GP_Context *src, GP_Context *dst, + unsigned int steps, + GP_ProgressCallback *callback) +{ + GP_FILTER_AREA_DEFAULT(src, dst); + + return GP_FilterPosterizeEx(&area, steps, callback); +} + +static inline GP_Context * +GP_FilterPosterizeAlloc(const GP_Context *src, unsigned int steps, + GP_ProgressCallback *callback) +{ + GP_FILTER_AREA_DEFAULT(src, NULL); + + return GP_FilterPosterizeExAlloc(&area, steps, callback); +} + +/* * Inverts the pixel value, i.e. sets it to max - val. */ int GP_FilterInvertEx(const GP_FilterArea *area, diff --git a/libs/filters/GP_BrightnessContrast.gen.c.t b/libs/filters/GP_BrightnessContrast.gen.c.t new file mode 100644 index 0000000..fc620f6 --- /dev/null +++ b/libs/filters/GP_BrightnessContrast.gen.c.t @@ -0,0 +1,39 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +%% extends "filter.point.c.t" + +%% block descr +Brightness and Contrast Point filter +%% endblock + +%% block body + +#include "core/GP_Clamp.h" + +%% macro filter_op_brightness_contrast(val, val_max) +GP_CLAMP_GENERIC(c * {{ val }} + b * {{ val_max }} + 0.5, 0, {{ val_max }}) +%%- endmacro + +{{ filter_point('BrightnessContrast', filter_op_brightness_contrast, 'float b, float c', 'b, c') }} + +%% endblock body diff --git a/libs/filters/GP_Posterize.gen.c.t b/libs/filters/GP_Posterize.gen.c.t new file mode 100644 index 0000000..d87fa0c --- /dev/null +++ b/libs/filters/GP_Posterize.gen.c.t @@ -0,0 +1,37 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +%% extends "filter.point.c.t" + +%% block descr +Posterize Point filter +%% endblock + +%% block body + +%% macro filter_op_posterize(val, val_max) +(({{ val }} + ({{ val_max }} / steps)/2) / ({{ val_max }} / steps)) * ({{ val_max }} / steps); +%%- endmacro + +{{ filter_point('Posterize', filter_op_posterize, 'unsigned int steps', 'steps') }} + +%% endblock body diff --git a/libs/filters/Makefile b/libs/filters/Makefile index e39d66e..c929aa7 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -4,7 +4,8 @@ include $(TOPDIR)/pre.mk STATS_FILTERS=GP_Histogram.gen.c
POINT_FILTERS=GP_GaussianNoise.gen.c GP_ApplyTables.gen.c GP_Invert.gen.c- GP_Brightness.gen.c GP_Contrast.gen.c + GP_Brightness.gen.c GP_Contrast.gen.c+ GP_BrightnessContrast.gen.c GP_Posterize.gen.c
ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py index c5ef3ab..d8bdd97 100644 --- a/pylib/gfxprim/filters/__init__.py +++ b/pylib/gfxprim/filters/__init__.py @@ -23,6 +23,8 @@ def _init(module): for name in ['Invert', 'InvertAlloc', 'Brightness', 'BrightnessAlloc', 'Contrast', 'ContrastAlloc', + 'BrightnessContrast', 'BrightnessContrastAlloc', + 'Posterize', 'PosterizeAlloc', 'Resize', 'ResizeAlloc', 'Rotate90', 'Rotate90Alloc', 'Rotate180', 'Rotate180Alloc', diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i index 59da75b..9bd6daf 100644 --- a/pylib/gfxprim/filters/filters.i +++ b/pylib/gfxprim/filters/filters.i @@ -31,6 +31,8 @@ ERROR_ON_NONZERO(GP_Filter ## funcname); FILTER_FUNC(Invert); FILTER_FUNC(Brightness); FILTER_FUNC(Contrast); +FILTER_FUNC(BrightnessContrast); +FILTER_FUNC(Posterize); %include "GP_Point.h"
/* Arithmetic filters */
http://repo.or.cz/w/gfxprim.git/commit/ddaf9058d046bbde16edfe2c4655a5690b043...
commit ddaf9058d046bbde16edfe2c4655a5690b043883 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 8 22:35:04 2013 +0100
filters: Clear free_table flag on GP_FilterTablesInit()
Fixes abort when GP_FilterTablesFree() tries to free() stack allocated tables structure.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/filters/GP_ApplyTables.c b/libs/filters/GP_ApplyTables.c index 7fcb591..bc03dda 100644 --- a/libs/filters/GP_ApplyTables.c +++ b/libs/filters/GP_ApplyTables.c @@ -30,6 +30,9 @@ static GP_Pixel *create_table(const GP_PixelTypeChannel *chan) GP_Pixel *table = malloc(table_size * sizeof(GP_Pixel)); GP_Pixel i;
+ GP_DEBUG(2, "Table for channel '%s' size %zu (%p)", + chan->name, table_size, table); + if (!table) { GP_DEBUG(1, "Malloc failed :("); return NULL; @@ -45,8 +48,14 @@ static void free_tables(GP_FilterTables *self) { unsigned int i;
- for (i = 0; i < GP_PIXELTYPE_MAX_CHANNELS; i++) + for (i = 0; i < GP_PIXELTYPE_MAX_CHANNELS; i++) { + + if (!self->table[i]) + break; + + GP_DEBUG(2, "Freeing table (%p)", self->table[i]); free(self->table[i]); + } }
int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx) @@ -70,6 +79,8 @@ int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx) } }
+ self->free_table = 0; + return 0; }
@@ -84,13 +95,13 @@ GP_FilterTables *GP_FilterTablesAlloc(const GP_Context *ctx) return NULL; }
- tables->free_table = 1; - if (GP_FilterTablesInit(tables, ctx)) { free(tables); return NULL; }
+ tables->free_table = 1; + return tables; }
@@ -100,6 +111,8 @@ void GP_FilterTablesFree(GP_FilterTables *self)
free_tables(self);
- if (self->free_table) + if (self->free_table) { + GP_DEBUG(2, "Freeing table itself"); free(self); + } }
-----------------------------------------------------------------------
Summary of changes: build/syms/Filters_symbols.txt | 15 +- doc/filters.txt | 202 ++++++-------------- doc/filters_python.txt | 207 ++++++++++++++++++++ doc/images/brightness/images.txt | 17 ++ doc/images/brightness/lenna_-0.2.png | Bin 0 -> 343625 bytes doc/images/brightness/lenna_-0.5.png | Bin 0 -> 162417 bytes doc/images/brightness/lenna_0.2.png | Bin 0 -> 392064 bytes doc/images/brightness/lenna_0.5.png | Bin 0 -> 335541 bytes doc/images/brightness/lenna_small_-0.2.png | Bin 0 -> 28475 bytes doc/images/brightness/lenna_small_-0.5.png | Bin 0 -> 13804 bytes doc/images/brightness/lenna_small_0.2.png | Bin 0 -> 31738 bytes doc/images/brightness/lenna_small_0.5.png | Bin 0 -> 27244 bytes doc/images/brightness_contrast/images.txt | 17 ++ doc/images/brightness_contrast/lenna_-0.2_0.8.png | Bin 0 -> 288118 bytes doc/images/brightness_contrast/lenna_-0.5_2.png | Bin 0 -> 330382 bytes doc/images/brightness_contrast/lenna_0.2_0.5.png | Bin 0 -> 313679 bytes doc/images/brightness_contrast/lenna_0.2_0.8.png | Bin 0 -> 372199 bytes doc/images/brightness_contrast/lenna_0.2_1.5.png | Bin 0 -> 388546 bytes doc/images/brightness_contrast/lenna_0.4_0.5.png | Bin 0 -> 314067 bytes .../brightness_contrast/lenna_small_-0.2_0.8.png | Bin 0 -> 24114 bytes .../brightness_contrast/lenna_small_-0.5_2.png | Bin 0 -> 26923 bytes .../brightness_contrast/lenna_small_0.2_0.5.png | Bin 0 -> 26101 bytes .../brightness_contrast/lenna_small_0.2_0.8.png | Bin 0 -> 30145 bytes .../brightness_contrast/lenna_small_0.2_1.5.png | Bin 0 -> 30713 bytes .../brightness_contrast/lenna_small_0.4_0.5.png | Bin 0 -> 26099 bytes doc/images/contrast/images.txt | 20 ++ doc/images/contrast/lenna_0.1.png | Bin 0 -> 161387 bytes doc/images/contrast/lenna_0.2.png | Bin 0 -> 221759 bytes doc/images/contrast/lenna_0.5.png | Bin 0 -> 313123 bytes doc/images/contrast/lenna_1.5.png | Bin 0 -> 427752 bytes doc/images/contrast/lenna_2.png | Bin 0 -> 361923 bytes doc/images/contrast/lenna_3.png | Bin 0 -> 284365 bytes doc/images/contrast/lenna_4.png | Bin 0 -> 222137 bytes doc/images/contrast/lenna_small_0.1.png | Bin 0 -> 14173 bytes doc/images/contrast/lenna_small_0.2.png | Bin 0 -> 18945 bytes doc/images/contrast/lenna_small_0.5.png | Bin 0 -> 26109 bytes doc/images/contrast/lenna_small_1.5.png | Bin 0 -> 33609 bytes doc/images/contrast/lenna_small_2.png | Bin 0 -> 28741 bytes doc/images/contrast/lenna_small_3.png | Bin 0 -> 22719 bytes doc/images/contrast/lenna_small_4.png | Bin 0 -> 18249 bytes doc/images/invert/images.txt | 8 + doc/images/invert/lenna_.png | Bin 0 -> 394328 bytes doc/images/invert/lenna_small_.png | Bin 0 -> 32009 bytes doc/images/mirror_h/images.txt | 8 + doc/images/mirror_h/lenna_.png | Bin 0 -> 389870 bytes doc/images/mirror_h/lenna_small_.png | Bin 0 -> 32009 bytes doc/images/mirror_v/images.txt | 8 + doc/images/mirror_v/lenna_.png | Bin 0 -> 390372 bytes doc/images/mirror_v/lenna_small_.png | Bin 0 -> 32040 bytes doc/images/posterize/images.txt | 20 ++ doc/images/posterize/lenna_2.png | Bin 0 -> 42875 bytes doc/images/posterize/lenna_3.png | Bin 0 -> 49708 bytes doc/images/posterize/lenna_4.png | Bin 0 -> 62363 bytes doc/images/posterize/lenna_5.png | Bin 0 -> 59237 bytes doc/images/posterize/lenna_6.png | Bin 0 -> 68968 bytes doc/images/posterize/lenna_small_2.png | Bin 0 -> 4858 bytes doc/images/posterize/lenna_small_3.png | Bin 0 -> 5145 bytes doc/images/posterize/lenna_small_4.png | Bin 0 -> 6113 bytes doc/images/posterize/lenna_small_5.png | Bin 0 -> 5904 bytes doc/images/posterize/lenna_small_6.png | Bin 0 -> 7078 bytes doc/images/regen.py | 40 ++++ doc/images/rotate_180/images.txt | 8 + doc/images/rotate_180/lenna_.png | Bin 0 -> 393966 bytes doc/images/rotate_180/lenna_small_.png | Bin 0 -> 31993 bytes doc/images/rotate_270/images.txt | 8 + doc/images/rotate_270/lenna_.png | Bin 0 -> 383865 bytes doc/images/rotate_270/lenna_small_.png | Bin 0 -> 31636 bytes doc/images/rotate_90/images.txt | 8 + doc/images/rotate_90/lenna_.png | Bin 0 -> 384169 bytes doc/images/rotate_90/lenna_small_.png | Bin 0 -> 31661 bytes include/filters/GP_Point.h | 65 ++++++- include/filters/GP_Rotate.h | 37 ---- libs/filters/GP_ApplyTables.c | 21 ++- libs/filters/GP_BrightnessContrast.gen.c.t | 39 ++++ libs/filters/GP_MirrorH.gen.c.t | 110 +++++++++++ libs/filters/GP_MirrorV.gen.c.t | 75 ------- libs/filters/GP_Noise.gen.c.t | 56 ------ libs/filters/GP_Point.gen.c.t | 57 ------ libs/filters/GP_Posterize.gen.c.t | 37 ++++ libs/filters/GP_Rotate.c | 149 +-------------- libs/filters/GP_Rotate.gen.c.t | 117 +++++++++++- libs/filters/Makefile | 5 +- pylib/gfxprim/filters/__init__.py | 2 + pylib/gfxprim/filters/filters.i | 2 + 84 files changed, 820 insertions(+), 538 deletions(-) create mode 100644 doc/images/brightness/images.txt create mode 100644 doc/images/brightness/lenna_-0.2.png create mode 100644 doc/images/brightness/lenna_-0.5.png create mode 100644 doc/images/brightness/lenna_0.2.png create mode 100644 doc/images/brightness/lenna_0.5.png create mode 100644 doc/images/brightness/lenna_small_-0.2.png create mode 100644 doc/images/brightness/lenna_small_-0.5.png create mode 100644 doc/images/brightness/lenna_small_0.2.png create mode 100644 doc/images/brightness/lenna_small_0.5.png create mode 100644 doc/images/brightness_contrast/images.txt create mode 100644 doc/images/brightness_contrast/lenna_-0.2_0.8.png create mode 100644 doc/images/brightness_contrast/lenna_-0.5_2.png create mode 100644 doc/images/brightness_contrast/lenna_0.2_0.5.png create mode 100644 doc/images/brightness_contrast/lenna_0.2_0.8.png create mode 100644 doc/images/brightness_contrast/lenna_0.2_1.5.png create mode 100644 doc/images/brightness_contrast/lenna_0.4_0.5.png create mode 100644 doc/images/brightness_contrast/lenna_small_-0.2_0.8.png create mode 100644 doc/images/brightness_contrast/lenna_small_-0.5_2.png create mode 100644 doc/images/brightness_contrast/lenna_small_0.2_0.5.png create mode 100644 doc/images/brightness_contrast/lenna_small_0.2_0.8.png create mode 100644 doc/images/brightness_contrast/lenna_small_0.2_1.5.png create mode 100644 doc/images/brightness_contrast/lenna_small_0.4_0.5.png create mode 100644 doc/images/contrast/images.txt create mode 100644 doc/images/contrast/lenna_0.1.png create mode 100644 doc/images/contrast/lenna_0.2.png create mode 100644 doc/images/contrast/lenna_0.5.png create mode 100644 doc/images/contrast/lenna_1.5.png create mode 100644 doc/images/contrast/lenna_2.png create mode 100644 doc/images/contrast/lenna_3.png create mode 100644 doc/images/contrast/lenna_4.png create mode 100644 doc/images/contrast/lenna_small_0.1.png create mode 100644 doc/images/contrast/lenna_small_0.2.png create mode 100644 doc/images/contrast/lenna_small_0.5.png create mode 100644 doc/images/contrast/lenna_small_1.5.png create mode 100644 doc/images/contrast/lenna_small_2.png create mode 100644 doc/images/contrast/lenna_small_3.png create mode 100644 doc/images/contrast/lenna_small_4.png create mode 100644 doc/images/invert/images.txt create mode 100644 doc/images/invert/lenna_.png create mode 100644 doc/images/invert/lenna_small_.png create mode 100644 doc/images/mirror_h/images.txt create mode 100644 doc/images/mirror_h/lenna_.png create mode 100644 doc/images/mirror_h/lenna_small_.png create mode 100644 doc/images/mirror_v/images.txt create mode 100644 doc/images/mirror_v/lenna_.png create mode 100644 doc/images/mirror_v/lenna_small_.png create mode 100644 doc/images/posterize/images.txt create mode 100644 doc/images/posterize/lenna_2.png create mode 100644 doc/images/posterize/lenna_3.png create mode 100644 doc/images/posterize/lenna_4.png create mode 100644 doc/images/posterize/lenna_5.png create mode 100644 doc/images/posterize/lenna_6.png create mode 100644 doc/images/posterize/lenna_small_2.png create mode 100644 doc/images/posterize/lenna_small_3.png create mode 100644 doc/images/posterize/lenna_small_4.png create mode 100644 doc/images/posterize/lenna_small_5.png create mode 100644 doc/images/posterize/lenna_small_6.png create mode 100644 doc/images/rotate_180/images.txt create mode 100644 doc/images/rotate_180/lenna_.png create mode 100644 doc/images/rotate_180/lenna_small_.png create mode 100644 doc/images/rotate_270/images.txt create mode 100644 doc/images/rotate_270/lenna_.png create mode 100644 doc/images/rotate_270/lenna_small_.png create mode 100644 doc/images/rotate_90/images.txt create mode 100644 doc/images/rotate_90/lenna_.png create mode 100644 doc/images/rotate_90/lenna_small_.png create mode 100644 libs/filters/GP_BrightnessContrast.gen.c.t create mode 100644 libs/filters/GP_MirrorH.gen.c.t delete mode 100644 libs/filters/GP_MirrorV.gen.c.t delete mode 100644 libs/filters/GP_Noise.gen.c.t delete mode 100644 libs/filters/GP_Point.gen.c.t create mode 100644 libs/filters/GP_Posterize.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.