Commit 3a985e08 authored by Kevin Cozens's avatar Kevin Cozens

Formatting changes.

	* operations/Makefile-operations.am:
	* operations/workshop/box-max.c:
	* operations/workshop/box-min.c: Formatting changes.

	* operations/workshop/box-percentile.c:
	* operations/workshop/c2g.c:
	* operations/workshop/demosaic-bimedian.c:
	* operations/workshop/demosaic-simple.c:
	* operations/workshop/disc-percentile.c:
	* operations/workshop/grey.c:
	* operations/workshop/hstack.c:
	* operations/workshop/kuwahara.c:
	* operations/workshop/kuwahara-max.c:
	* operations/workshop/kuwahara-min.c:
	* operations/workshop/lens-correct.c:
	* operations/workshop/line-profile.c:
	* operations/workshop/mandelbrot.c:
	* operations/workshop/max-envelope.c:
	* operations/workshop/min-envelope.c:
	* operations/workshop/snn-percentile.c:
	* operations/workshop/stress.c: Updated to new chanting API.

svn path=/trunk/; revision=1916
parent 5b9793aa
2008-01-26 Kevin Cozens <kcozens@cvs.gnome.org>
* operations/Makefile-operations.am:
* operations/workshop/box-max.c:
* operations/workshop/box-min.c: Formatting changes.
* operations/workshop/box-percentile.c:
* operations/workshop/c2g.c:
* operations/workshop/demosaic-bimedian.c:
* operations/workshop/demosaic-simple.c:
* operations/workshop/disc-percentile.c:
* operations/workshop/grey.c:
* operations/workshop/hstack.c:
* operations/workshop/kuwahara.c:
* operations/workshop/kuwahara-max.c:
* operations/workshop/kuwahara-min.c:
* operations/workshop/lens-correct.c:
* operations/workshop/line-profile.c:
* operations/workshop/mandelbrot.c:
* operations/workshop/max-envelope.c:
* operations/workshop/min-envelope.c:
* operations/workshop/snn-percentile.c:
* operations/workshop/stress.c: Updated to new chanting API.
2008-01-25 Øyvind Kolås <pippin@gimp.org>
* gegl/gegl-chant.h: added GEGL_CHANT() casting macro for casting
......
......@@ -14,7 +14,7 @@ all-local: $(SOBJS)
CFLAGS += @DEP_CFLAGS@ @BABL_CFLAGS@ @CPPFLAGS@ \
-I$(srcdir) -I$(top_srcdir) \
-I$(top_srcdir)/gegl \
-I$(top_srcdir)/gegl \
-I$(top_srcdir)/gegl/buffer \
-I$(top_srcdir)/gegl/operation \
-I$(top_srcdir)/gegl/property-types \
......
......@@ -26,37 +26,9 @@ gegl_chant_double (radius, 0.0, 200.0, 4.0,
#define GEGL_CHANT_C_FILE "box-max.c"
#include "gegl-chant.h"
static void hor_max (GeglBuffer *src,
GeglBuffer *dst,
gint radius);
static void ver_max (GeglBuffer *src,
GeglBuffer *dst,
gint radius);
#include <math.h>
#include <stdio.h>
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
temp = gegl_buffer_new (gegl_buffer_get_extent (input),
babl_format ("RGBA float"));
hor_max (input, temp, o->radius);
ver_max (temp, output, o->radius);
g_object_unref (temp);
return TRUE;
}
static inline gfloat
get_max_component (gfloat *buf,
gint buf_width,
......@@ -169,7 +141,10 @@ ver_max (GeglBuffer *src,
g_free (dst_buf);
}
#include <math.h>
static void prepare (GeglOperation *operation)
{
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static void tickle (GeglOperation *operation)
{
......@@ -179,27 +154,42 @@ static void tickle (GeglOperation *operation)
ceil (GEGL_CHANT_PROPERTIES (operation)->radius);
}
static void prepare (GeglOperation *operation)
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
temp = gegl_buffer_new (gegl_buffer_get_extent (input),
babl_format ("RGBA float"));
hor_max (input, temp, o->radius);
ver_max (temp, output, o->radius);
g_object_unref (temp);
return TRUE;
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;
operation_class->prepare = prepare;
operation_class->tickle = tickle;
operation_class->name = "box-max";
operation_class->categories = "misc";
operation_class->name = "box-max";
operation_class->categories = "misc";
operation_class->description =
"Sets the target pixel to the value of the maximum value in a box surrounding the pixel.";
}
......
......@@ -26,37 +26,8 @@ gegl_chant_double (radius, 0.0, 200.0, 4.0,
#define GEGL_CHANT_C_FILE "box-min.c"
#include "gegl-chant.h"
static void hor_min (GeglBuffer *src,
GeglBuffer *dst,
gint radius);
static void ver_min (GeglBuffer *src,
GeglBuffer *dst,
gint radius);
#include <stdio.h>
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
temp = gegl_buffer_new (gegl_buffer_get_extent (input),
babl_format ("RGBA float"));
hor_min (input, temp, o->radius);
ver_min (temp, output, o->radius);
g_object_unref (temp);
return TRUE;
}
#include <math.h>
static inline gfloat
get_min_component (gfloat *buf,
......@@ -170,7 +141,10 @@ ver_min (GeglBuffer *src,
g_free (dst_buf);
}
#include <math.h>
static void prepare (GeglOperation *operation)
{
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static void tickle (GeglOperation *operation)
{
......@@ -182,27 +156,42 @@ static void tickle (GeglOperation *operation)
area->bottom = GEGL_CHANT_PROPERTIES (operation)->radius;
}
static void prepare (GeglOperation *operation)
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
temp = gegl_buffer_new (gegl_buffer_get_extent (input),
babl_format ("RGBA float"));
hor_min (input, temp, o->radius);
ver_min (temp, output, o->radius);
g_object_unref (temp);
return TRUE;
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;
operation_class->prepare = prepare;
operation_class->tickle = tickle;
operation_class->name = "box-min";
operation_class->categories = "misc";
operation_class->name = "box-min";
operation_class->categories = "misc";
operation_class->description =
"Sets the target pixel to the value of the minimum value in a box surrounding the pixel.";
}
......
......@@ -17,8 +17,7 @@
* 2007 Øyvind Kolås <oeyvindk@hig.no>
*/
#if GEGL_CHANT_PROPERTIES
#define MAX_SAMPLES 20000 /* adapted to max level of radius */
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (radius, 0.0, 70.0, 4.0,
"Radius of square pixel region, (width and height will be radius*2+1.")
......@@ -26,55 +25,53 @@ gegl_chant_double (percentile, 0.0, 100.0, 50, "The percentile to compute, defau
#else
#define GEGL_CHANT_NAME box_percentile
#define GEGL_CHANT_SELF "box-percentile.c"
#define GEGL_CHANT_DESCRIPTION "Sets the target pixel to the color corresponding to a given percentile when colors are sorted by luminance."
#define GEGL_CHANT_CATEGORIES "misc"
#define MAX_SAMPLES 20000 /* adapted to max level of radius */
#define GEGL_CHANT_AREA_FILTER
#define GEGL_CHANT_PREPARE
#define GEGL_CHANT_TYPE_AREA_FILTER
#define GEGL_CHANT_C_FILE "box-percentile.c"
#include "gegl-old-chant.h"
#include "gegl-chant.h"
#include <stdio.h>
#include <math.h>
static void median (GeglBuffer *src,
GeglBuffer *dst,
gint radius,
gdouble rank);
#include <stdio.h>
static void prepare (GeglOperation *operation)
{
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static void tickle (GeglOperation *operation)
{
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
area->left = area->right = area->top = area->bottom = ceil (o->radius);
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglOperationFilter *filter;
GeglChantOperation *self;
filter = GEGL_OPERATION_FILTER (operation);
self = GEGL_CHANT_OPERATION (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp_in;
GeglRectangle compute = gegl_operation_compute_input_request (operation, "input", result);
if (o->radius < 1.0)
{
GeglBuffer *temp_in;
GeglRectangle compute = gegl_operation_compute_input_request (operation, "input", result);
if (self->radius < 1.0)
{
output = g_object_ref (input);
}
else
{
temp_in = gegl_buffer_create_sub_buffer (input, &compute);
output = g_object_ref (input);
}
else
{
temp_in = gegl_buffer_create_sub_buffer (input, &compute);
median (temp_in, output, self->radius, self->percentile / 100.0);
g_object_unref (temp_in);
}
median (temp_in, output, o->radius, o->percentile / 100.0);
g_object_unref (temp_in);
}
return TRUE;
......@@ -208,14 +205,24 @@ median (GeglBuffer *src,
g_free (dst_buf);
}
#include <math.h>
static void tickle (GeglOperation *operation)
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantOperation *filter = GEGL_CHANT_OPERATION (operation);
area->left = area->right = area->top = area->bottom =
ceil (filter->radius);
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;
operation_class->prepare = prepare;
operation_class->tickle = tickle;
operation_class->name = "box-percentile";
operation_class->categories = "misc";
operation_class->description =
"Sets the target pixel to the color corresponding to a given percentile when colors are sorted by luminance.";
}
#endif
......@@ -17,7 +17,7 @@
* Ivar Farup <ivarf@hig.no>
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_int (radius, 2, 5000.0, 384, "neighbourhood taken into account")
gegl_chant_int (samples, 0, 1000, 3, "number of samples to do")
......@@ -26,18 +26,17 @@ gegl_chant_boolean (same_spray, FALSE, "")
gegl_chant_double (rgamma, 0.0, 8.0, 1.8, "gamma applied to radial distribution")
gegl_chant_double (strength, -8, 8, 0.5, "how much the local optimum separation should be taken into account.")
gegl_chant_double (gamma, 0.0, 10.0, 1.6, "post correction gamma.")
#else
#define GEGL_CHANT_NAME c2g
#define GEGL_CHANT_SELF "c2g.c"
#define GEGL_CHANT_DESCRIPTION "Color to grayscale conversion that uses, spatial color differences to perform local grayscale contrast enhancement."
#define GEGL_CHANT_CATEGORIES "enhance"
#else
#define GEGL_CHANT_AREA_FILTER
#define GEGL_CHANT_PREPARE
#define GEGL_CHANT_TYPE_AREA_FILTER
#define GEGL_CHANT_C_FILE "c2g.c"
#include "gegl-old-chant.h"
#include "gegl-chant.h"
#include <math.h>
#include <stdlib.h>
#include "envelopes.h"
#define sq(a) ((a)*(a))
static void c2g (GeglBuffer *src,
......@@ -50,40 +49,37 @@ static void c2g (GeglBuffer *src,
gfloat strength,
gfloat gamma);
#include <stdlib.h>
static void prepare (GeglOperation *operation)
{
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static void tickle (GeglOperation *operation)
{
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
area->left = area->right = area->top = area->bottom = ceil (o->radius);
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglOperationFilter *filter;
GeglChantOperation *self;
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp_in;
GeglRectangle compute = gegl_operation_compute_input_request (operation, "input", result);
filter = GEGL_OPERATION_FILTER (operation);
self = GEGL_CHANT_OPERATION (operation);
temp_in = gegl_buffer_create_sub_buffer (input, &compute);
{
GeglBuffer *temp_in;
GeglRectangle compute = gegl_operation_compute_input_request (operation, "input", result);
temp_in = gegl_buffer_create_sub_buffer (input, &compute);
c2g (temp_in, output, self->radius, self->samples, self->iterations, self->same_spray, self->rgamma, self->strength, self->gamma);
g_object_unref (temp_in);
}
c2g (temp_in, output, o->radius, o->samples, o->iterations, o->same_spray,
o->rgamma, o->strength, o->gamma);
g_object_unref (temp_in);
return TRUE;
}
#include "envelopes.h"
static void c2g (GeglBuffer *src,
GeglBuffer *dst,
gint radius,
......@@ -98,7 +94,6 @@ static void c2g (GeglBuffer *src,
gfloat *src_buf;
gfloat *dst_buf;
src_buf = g_malloc0 (gegl_buffer_get_pixel_count (src) * 4 * 4);
dst_buf = g_malloc0 (gegl_buffer_get_pixel_count (dst) * 4 * 4);
......@@ -167,12 +162,24 @@ static void c2g (GeglBuffer *src,
g_free (dst_buf);
}
static void tickle (GeglOperation *operation)
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantOperation *filter = GEGL_CHANT_OPERATION (operation);
area->left = area->right = area->top = area->bottom =
ceil (filter->radius);
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;
operation_class->prepare = prepare;
operation_class->tickle = tickle;
operation_class->name = "c2g";
operation_class->categories = "enhance";
operation_class->description =
"Color to grayscale conversion that uses, spatial color differences to perform local grayscale contrast enhancement.";
}
#endif
......@@ -16,38 +16,17 @@
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
* Copyright 2008 Bradley Broom <bmbroom@gmail.com>
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_int (pattern, 0, 3, 0, "Bayer pattern used, 0 seems to work for some nikon files, 2 for some Fuji files.")
#else
#define GEGL_CHANT_NAME demosaic_bimedian
#define GEGL_CHANT_SELF "demosaic-bimedian.c"
#define GEGL_CHANT_DESCRIPTION "Performs a grayscale2color demosaicing of an image, using bimedian interpolation."
#define GEGL_CHANT_CATEGORIES "blur"
#define GEGL_CHANT_AREA_FILTER
#include "gegl-old-chant.h"
static void
demosaic (GeglChantOperation *op,
GeglBuffer *src,
GeglBuffer *dst);
#else
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
#define GEGL_CHANT_TYPE_AREA_FILTER
#define GEGL_CHANT_C_FILE "demosaic-bimedian.c"
demosaic (self, input, output);
#include "gegl-chant.h"
return TRUE;
}
/* Returns the median of four floats. We define the median as the average of
* the central two elements.
......@@ -70,12 +49,12 @@ m4 (gfloat a, gfloat b, gfloat c, gfloat d)
t = c;
c = b;
if (a > t)
{
b = a;
a = t;
}
{
b = a;
a = t;
}
else
b = t;
b = t;
}
/* Return average of central two elements. */
if (d >= c) /* Sorted order would be abcd */
......@@ -94,7 +73,7 @@ m4 (gfloat a, gfloat b, gfloat c, gfloat d)
* of dst_extent.
*/
static void
demosaic (GeglChantOperation *op,
demosaic (GeglChantO *op,
GeglBuffer *src,
GeglBuffer *dst)
{
......@@ -107,78 +86,78 @@ demosaic (GeglChantOperation *op,
src_buf = g_malloc0 (gegl_buffer_get_pixel_count (src) * 4);
dst_buf = g_malloc0 (gegl_buffer_get_pixel_count (dst) * 4 * 3);
gegl_buffer_get (src, 1.0, NULL, babl_format ("Y float"), src_buf,
GEGL_AUTO_ROWSTRIDE);
GEGL_AUTO_ROWSTRIDE);
offset = ROW + COL;
doffset = 0;
for (y=dst_extent->y; y<dst_extent->height + dst_extent->y; y++)
{
for (x=dst_extent->x; x<dst_extent->width + dst_extent->x; x++)
{
gfloat red=0.0;
gfloat green=0.0;
gfloat blue=0.0;
if ((y + op->pattern%2)%2==0)
{
if ((x+op->pattern/2)%2==1)
{
/* GRG
* BGB
* GRG
*/
blue =(src_buf[offset-COL]+src_buf[offset+COL])/2.0;
green=src_buf[offset];
red =(src_buf[offset-ROW]+src_buf[offset+ROW])/2.0;
}
else
{
/* RGR
* GBG
* RGR
*/
blue =src_buf[offset];
green=m4(src_buf[offset-ROW], src_buf[offset-COL],
src_buf[offset+COL], src_buf[offset+ROW]);
red =m4(src_buf[offset-ROW-COL], src_buf[offset-ROW+COL],
src_buf[offset+ROW-COL], src_buf[offset+ROW+COL]);
}
}
else
{
if ((x+op->pattern/2)%2==1)
{
/* BGB
* GRG
* BGB
*/
blue =m4(src_buf[offset-ROW-COL], src_buf[offset-ROW+COL],
src_buf[offset+ROW-COL], src_buf[offset+ROW+COL]);
green=m4(src_buf[offset-ROW], src_buf[offset-COL],
src_buf[offset+COL], src_buf[offset+ROW]);
red =src_buf[offset];
}
else
{
/* GBG
* RGR
* GBG
*/
blue =(src_buf[offset-ROW]+src_buf[offset+ROW])/2.0;
green=src_buf[offset];
red =(src_buf[offset-COL]+src_buf[offset+COL])/2.0;
}
}
dst_buf [doffset*3+0] = red;
dst_buf [doffset*3+1] = green;
dst_buf [doffset*3+2] = blue;
offset++;
doffset++;
}
{
gfloat red=0.0;
gfloat green=0.0;
gfloat blue=0.0;
if ((y + op->pattern%2)%2==0)
{
if ((x+op->pattern/2)%2==1)
{
/* GRG
* BGB
* GRG
*/
blue =(src_buf[offset-COL]+src_buf[offset+COL])/2.0;
green=src_buf[offset];
red =(src_buf[offset-ROW]+src_buf[offset+ROW])/2.0;
}
else
{
/* RGR
* GBG
* RGR
*/
blue =src_buf[offset];
green=m4(src_buf[offset-ROW], src_buf[offset-COL],
src_buf[offset+COL], src_buf[offset+ROW]);
red =m4(src_buf[offset-ROW-COL], src_buf[offset-ROW+COL],
src_buf[offset+ROW-COL], src_buf[offset+ROW+COL]);
}
}
else
{
if ((x+op->pattern/2)%2==1)
{
/* BGB
* GRG
* BGB
*/
blue =m4(src_buf[offset-ROW-COL], src_buf[offset-ROW+COL],
src_buf[offset+ROW-COL], src_buf[offset+ROW+COL]);
green=m4(src_buf[offset-ROW], src_buf[offset-COL],
src_buf[offset+COL], src_buf[offset+ROW]);
red =src_buf[offset];
}
else
{
/* GBG
* RGR
* GBG
*/
blue =(src_buf[offset-ROW]+src_buf[offset+ROW])/2.0;
green=src_buf[offset];
red =(src_buf[offset-COL]+src_buf[offset+COL])/2.0;
}
}
dst_buf [doffset*3+0] = red;
dst_buf [doffset*3+1] = green;
dst_buf [doffset*3+2] = blue;
offset++;
doffset++;
}
offset+=2;
}
......@@ -196,4 +175,36 @@ static void tickle (GeglOperation *operation)
area->left = area->top = 1;
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
demosaic (o, input, output);
return TRUE;
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;