[Gimp-developer] GEGL GSOC Application



Hi,

      I am Sourav De, 3rd year undergraduate student of the department of Computer Science and Engineering at Indian Institute of Technology, Kharagpur. I'd like to participate in the GEGL implementation project for G'Soc 2012. I've applied for this last year too. I'm very interested in Image Processing and have done some project work on Artistic Rendition.

     Please find the attached patch file for alien-filter I've experimented with and let me know if there is any mistake. Thanking you,

--
Sourav De
3rd Year Undergraduate Student
Department of Computer Science and Engineering
IIT KHARAGPUR

commit 9588f5aed0fc76ca6c13d0982fa669c58d825d8e
Author: Sourav De <souravde1991 gmail com>
Date:   Mon Mar 26 21:36:41 2012 +0530

    Sourav Changes

diff --git a/operations/common/alien-map.c b/operations/common/alien-map.c
new file mode 100644
index 0000000..f947c2b
--- /dev/null
+++ b/operations/common/alien-map.c
@@ -0,0 +1,100 @@
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+#ifdef GEGL_CHANT_PROPERTIES
+
+gegl_chant_boolean (redMode, _("Modify Red Channel"), 1,_("blah blah"))
+gegl_chant_boolean (greenMode, _("Modify Green Channel"), 1,_("blah blah"))
+gegl_chant_boolean (blueMode, _("Modify Blue Channel"), 1,_("blah blah"))
+
+gegl_chant_double (redFrequency, _("Red Frequency"), 0.0, 20.0, 1.0,_("blah blah"))
+gegl_chant_double (redAngle, _("Red Phase Shift"), 0.0, 360.0, 0.0,_("blah blah"))
+gegl_chant_double (greenFrequency, _("Green Frequency"), 0.0, 20.0, 1.0,_("blah blah"))
+gegl_chant_double (greenAngle, _("Green Phase Shift"), 0.0, 360.0, 0.0,_("blah blah"))
+gegl_chant_double (blueFrequency, _("Blue Frequency"), 0.0, 20.0, 1.0,_("blah blah"))
+gegl_chant_double (blueAngle, _("Blue Phase Shift"), 0.0, 360.0, 0.0,_("blah blah"))
+
+#else
+#define GEGL_CHANT_TYPE_AREA_FILTER
+#define GEGL_CHANT_C_FILE "alien-map.c"
+
+#include "gegl-chant.h"
+#include <math.h>
+#include <stdio.h>
+
+static void alien_map_filter(GeglBuffer *src, const GeglRectangle *src_rect, GeglBuffer *dst,const GeglRectangle *dst_rect,GeglOperation *operation)
+{
+	gint x,y;
+  gfloat *src_buf;
+  gfloat *dst_buf;
+	gint src_width = src_rect->width;
+	
+	GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+	
+  src_buf = g_new0 (gfloat, src_rect->width * src_rect->height * 4);
+  dst_buf = g_new0 (gfloat, dst_rect->width * dst_rect->height * 4);
+	
+	gegl_buffer_get (src, 1.0, src_rect, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
+	
+	for (y=0; y<dst_rect->height; y++)
+	{
+    for (x=0; x<dst_rect->width; x++)
+    {
+    	gint k = (x + y*src_width)*4;
+    	
+    	gfloat v1 = src_buf[k];
+    	gfloat v2 = src_buf[k+1];
+    	gfloat v3 = src_buf[k+2];
+    	
+    	if (o->redMode)
+				v1 = sin((v1 * o->redFrequency + o->redAngle / 180.0 ) * G_PI);
+				
+			if (o->greenMode)
+				v2 = sin((v2 * o->greenFrequency + o->greenAngle / 180.0) * G_PI);
+
+			if (o->blueMode)
+				v3 = sin((v3 * o->blueFrequency + o->blueAngle / 180.0) * G_PI);
+    	
+    	dst_buf[k] = v1;
+    	dst_buf[k+1] = v2;
+    	dst_buf[k+2] = v3;
+    	dst_buf[k+3] = src_buf[k+3];
+    }
+  }
+	
+	gegl_buffer_set (dst, dst_rect, babl_format ("RGBA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
+	
+	g_free (src_buf);
+  g_free (dst_buf);
+}
+
+static void prepare (GeglOperation *operation)
+{
+  gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
+  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
+}
+
+static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result)
+{
+  GeglRectangle compute = gegl_operation_get_required_for_output (operation, "input",result);
+  alien_map_filter (input, &compute, output, result, operation);
+  return  TRUE;
+}
+
+static void gegl_chant_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;
+  operation_class->prepare = prepare;
+
+  operation_class->name        = "gegl:alien-map";
+  operation_class->categories  = "misc";
+  operation_class->description = _("Alien Color Map");
+}
+
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]