Commit 7dce5532 authored by Øyvind Kolås's avatar Øyvind Kolås

added boolean toggle for whether the same random spray is applied to every

* operations/workshop/envelopes.h: added boolean toggle for whether
the same random spray is applied to every pixel and a parameter
specifying a radial distribution modifier, with a new default value
of 1.8.
* operations/workshop/c2g.c: Extend the envelope using operations ..
* operations/workshop/max-envelope.c: .. to use both same_spray and
* operations/workshop/min-envelope.c: .. radial gamma.
* operations/workshop/stress.c:

svn path=/trunk/; revision=1566
parent ebd36a22
2007-06-15 Øyvind Kolås <pippin@gimp.org>
* operations/workshop/envelopes.h: added boolean toggle for whether
the same random spray is applied to every pixel and a parameter
specifying a radial distribution modifier, with a new default value
of 1.8.
* operations/workshop/c2g.c: Extend the envelope using operations ..
* operations/workshop/max-envelope.c: .. to use both same_spray and
* operations/workshop/min-envelope.c: .. radial gamma.
* operations/workshop/stress.c:
2007-06-12 Øyvind Kolås <pippin@gimp.org>
New operations should be added to the workshop before being considered
......
......@@ -24,6 +24,8 @@
gegl_chant_int (radius, 2, 5000.0, 384, "neighbourhood taken into account")
gegl_chant_int (samples, 0, 1000, 3, "number of samples to do")
gegl_chant_int (iterations, 0, 1000.0, 23, "number of iterations (length of exposure)")
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
......@@ -44,10 +46,11 @@ static void c2g (GeglBuffer *src,
gint radius,
gint samples,
gint iterations,
gboolean same_spray,
gdouble rgamma,
gfloat strength,
gfloat gamma);
static void compute_luts(void);
#include <stdlib.h>
static gboolean
......@@ -86,7 +89,7 @@ process (GeglOperation *operation,
"height", compute.height,
NULL);
c2g (temp_in, output, self->radius, self->samples, self->iterations, self->strength, self->gamma);
c2g (temp_in, output, self->radius, self->samples, self->iterations, self->same_spray, self->rgamma, self->strength, self->gamma);
g_object_unref (temp_in);
......@@ -112,6 +115,8 @@ static void c2g (GeglBuffer *src,
gint radius,
gint samples,
gint iterations,
gboolean same_spray,
gdouble rgamma,
gfloat strength,
gfloat gamma)
{
......@@ -119,7 +124,6 @@ static void c2g (GeglBuffer *src,
gfloat *src_buf;
gfloat *dst_buf;
compute_luts ();
src_buf = g_malloc0 (src->width * src->height * 4 * 4);
dst_buf = g_malloc0 (dst->width * dst->height * 4 * 4);
......@@ -140,6 +144,8 @@ static void c2g (GeglBuffer *src,
x, y,
radius, samples,
iterations,
same_spray,
rgamma,
min_envelope, max_envelope);
{ /* now having a local blackpoint and a local white point
......
......@@ -23,16 +23,16 @@
static gfloat lut_cos[ANGLE_PRIME];
static gfloat lut_sin[ANGLE_PRIME];
static gfloat radiuses[RADIUS_PRIME];
static gboolean luts_computed = FALSE;
static gdouble luts_computed = 0.0;
static gint angle_no=0;
static gint radius_no=0;
static void compute_luts(void)
static void compute_luts(gdouble rgamma)
{
gint i;
if (luts_computed)
if (luts_computed==rgamma)
return;
luts_computed = TRUE;
luts_computed = rgamma;
for (i=0;i<ANGLE_PRIME;i++)
{
......@@ -42,7 +42,7 @@ static void compute_luts(void)
}
for (i=0;i<RADIUS_PRIME;i++)
{
radiuses[i] = (random() / (RAND_MAX*1.0));
radiuses[i] = pow(random() / (RAND_MAX*1.0), rgamma);
}
}
......@@ -142,16 +142,18 @@ retry: /* if we've sampled outside the valid image
}
}
static void compute_envelopes (gfloat *buf,
gint width,
gint height,
gint x,
gint y,
gint radius,
gint samples,
gint iterations,
gfloat *min_envelope,
gfloat *max_envelope)
static void compute_envelopes (gfloat *buf,
gint width,
gint height,
gint x,
gint y,
gint radius,
gint samples,
gint iterations,
gboolean same_spray,
gdouble rgamma,
gfloat *min_envelope,
gfloat *max_envelope)
{
gint i;
gint c;
......@@ -160,7 +162,13 @@ static void compute_envelopes (gfloat *buf,
gfloat bright_avg[4] = {0,0,0,0};
gfloat *pixel = buf + (width*y+x)*4;
compute_luts();
compute_luts(rgamma);
if (same_spray)
{
angle_no = 0;
radius_no = 0;
}
for (i=0;i<iterations;i++)
{
......
......@@ -23,6 +23,8 @@
gegl_chant_int (radius, 2, 5000.0, 50, "neighbourhood taken into account")
gegl_chant_int (samples, 0, 1000, 3, "number of samples to do")
gegl_chant_int (iterations, 0, 1000.0, 20, "number of iterations (length of exposure)")
gegl_chant_boolean (same_spray, FALSE, "")
gegl_chant_double (rgamma, 0.0, 8.0, 1.8, "gamma applied to radial distribution")
#else
#define GEGL_CHANT_NAME max_envelope
......@@ -39,7 +41,9 @@ static void max_envelope (GeglBuffer *src,
GeglBuffer *dst,
gint radius,
gint samples,
gint iterations);
gint iterations,
gboolean same_spray,
gdouble rgamma);
#include <stdlib.h>
......@@ -86,7 +90,7 @@ process (GeglOperation *operation,
"height", compute.height,
NULL);
max_envelope (temp_in, output, self->radius, self->samples, self->iterations);
max_envelope (temp_in, output, self->radius, self->samples, self->iterations, self->same_spray, self->rgamma);
g_object_unref (temp_in);
}
......@@ -111,7 +115,9 @@ static void max_envelope (GeglBuffer *src,
GeglBuffer *dst,
gint radius,
gint samples,
gint iterations)
gint iterations,
gboolean same_spray,
gdouble rgamma)
{
gint x,y;
gfloat *src_buf;
......@@ -136,6 +142,8 @@ static void max_envelope (GeglBuffer *src,
x, y,
radius, samples,
iterations,
same_spray,
rgamma,
NULL, max_envelope);
{
......
......@@ -23,6 +23,8 @@
gegl_chant_int (radius, 2, 5000.0, 50, "neighbourhood taken into account")
gegl_chant_int (samples, 0, 1000, 3, "number of samples to do")
gegl_chant_int (iterations, 0, 1000.0, 20, "number of iterations (length of exposure)")
gegl_chant_boolean (same_spray, FALSE, "")
gegl_chant_double (rgamma, 0.0, 8.0, 1.8, "gamma applied to radial distribution")
#else
#define GEGL_CHANT_NAME min_envelope
......@@ -39,7 +41,9 @@ static void min_envelope (GeglBuffer *src,
GeglBuffer *dst,
gint radius,
gint samples,
gint iterations);
gint iterations,
gboolean same_spray,
gdouble rgamma);
#include <stdlib.h>
......@@ -86,7 +90,7 @@ process (GeglOperation *operation,
"height", compute.height,
NULL);
min_envelope (temp_in, output, self->radius, self->samples, self->iterations);
min_envelope (temp_in, output, self->radius, self->samples, self->iterations, self->same_spray, self->rgamma);
g_object_unref (temp_in);
}
......@@ -111,7 +115,9 @@ static void min_envelope (GeglBuffer *src,
GeglBuffer *dst,
gint radius,
gint samples,
gint iterations)
gint iterations,
gboolean same_spray,
gdouble rgamma)
{
gint x,y;
gfloat *src_buf;
......@@ -136,6 +142,8 @@ static void min_envelope (GeglBuffer *src,
x, y,
radius, samples,
iterations,
same_spray,
rgamma,
min_envelope, NULL);
{
......
......@@ -25,6 +25,8 @@
gegl_chant_int (radius, 2, 5000.0, 40, "neighbourhood taken into account")
gegl_chant_int (samples, 0, 1000, 3, "number of samples to do")
gegl_chant_int (iterations, 0, 1000.0, 34, "number of iterations (length of exposure)")
gegl_chant_boolean (same_spray, FALSE, "use the same spray for all pixels")
gegl_chant_double (rgamma, 0.0, 8.0, 1.8, "gamma applied to radial distribution")
gegl_chant_double (strength, -10.0, 10.0, 1.0, "amoung of correction 0=none 1.0=full")
gegl_chant_double (gamma, 0.0, 10.0, 1.6, "post correction gamma.")
#else
......@@ -46,6 +48,8 @@ static void stress (GeglBuffer *src,
gint radius,
gint samples,
gint iterations,
gboolean same_spray,
gdouble rgamma,
gdouble strength,
gdouble gamma);
......@@ -70,6 +74,8 @@ process (GeglOperation *operation,
self->radius,
self->samples,
self->iterations,
self->same_spray,
self->rgamma,
self->strength,
self->gamma);
......@@ -84,6 +90,8 @@ static void stress (GeglBuffer *src,
gint radius,
gint samples,
gint iterations,
gboolean same_spray,
gdouble rgamma,
gdouble strength,
gdouble gamma)
{
......@@ -112,6 +120,8 @@ static void stress (GeglBuffer *src,
x, y,
radius, samples,
iterations,
same_spray,
rgamma,
min_envelope, max_envelope);
{
gint c;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment