[gegl] sobel/laplace: remove trailing white space, poke indentation



commit aab9fd3650f27512e50f3f46573c614b2e9c2a41
Author: �yvind Kolås <pippin gimp org>
Date:   Tue Apr 19 18:31:01 2011 +0100

    sobel/laplace: remove trailing white space, poke indentation

 operations/common/edge-laplace.c |   76 ++++++++++++++++++++------------------
 operations/common/edge-sobel.c   |   76 +++++++++++++++++++------------------
 2 files changed, 79 insertions(+), 73 deletions(-)
---
diff --git a/operations/common/edge-laplace.c b/operations/common/edge-laplace.c
index deae76c..3475d0b 100644
--- a/operations/common/edge-laplace.c
+++ b/operations/common/edge-laplace.c
@@ -14,11 +14,11 @@
  * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
  *
  */
- 
+
 /*
  * Copyright 2011 Victor Oliveira <victormatheus gmail com>
  */
- 
+
 #include "config.h"
 #include <glib/gi18n-lib.h>
 
@@ -40,7 +40,7 @@ edge_laplace (GeglBuffer          *src,
               const GeglRectangle *src_rect,
               GeglBuffer          *dst,
               const GeglRectangle *dst_rect);
-              
+
 #include <stdio.h>
 
 static void prepare (GeglOperation *operation)
@@ -70,12 +70,12 @@ process (GeglOperation       *operation,
 
 static void
 minmax  (gfloat  x1,
-	 gfloat  x2,
-	 gfloat  x3,
-	 gfloat  x4,
-	 gfloat  x5,
-	 gfloat *min_result,
-	 gfloat *max_result)
+         gfloat  x2,
+         gfloat  x3,
+         gfloat  x4,
+         gfloat  x5,
+         gfloat *min_result,
+         gfloat *max_result)
 {
   gfloat min1, min2, max1, max2;
 
@@ -132,47 +132,51 @@ edge_laplace (GeglBuffer          *src,
   temp_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);
+  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++)
       {
         gfloat *src_pix;
-        
+
         gfloat gradient[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-                
+
         gint c;
 
         gfloat minval, maxval;
-        
+
         gint i=x+LAPLACE_RADIUS, j=y+LAPLACE_RADIUS;
         offset = i + j * src_width;
         src_pix = src_buf + offset * 4;
-        
+
         for (c=0;c<3;c++)
-        {
-          minmax (src_pix[c-src_width*4], src_pix[c+src_width*4],
-                  src_pix[c-4], src_pix[c+4], src_pix[c],
-                  &minval, &maxval); /* four-neighbourhood */
-          
-          gradient[c] = 0.5f * fmaxf((maxval-src_pix[c]), (src_pix[c]-minval));
-          
-          gradient[c] = (src_pix[c-4-src_width*4]+     src_pix[c-src_width*4]+src_pix[c+4-src_width*4] + \
-                         src_pix[c-4]            -8.0f*src_pix[c]            +src_pix[c+4]             + \
-                         src_pix[c-4+src_width*4]+     src_pix[c+src_width*4]+src_pix[c+4+src_width*4]) > 0.0f?
-                        gradient[c] : -1.0f*gradient[c];
+          {
+            minmax (src_pix[c-src_width*4], src_pix[c+src_width*4],
+                    src_pix[c-4], src_pix[c+4], src_pix[c],
+                    &minval, &maxval); /* four-neighbourhood */
+
+            gradient[c] = 0.5f * fmaxf((maxval-src_pix[c]), (src_pix[c]-minval));
+
+            gradient[c] = (src_pix[c-4-src_width*4] +
+                           src_pix[c-src_width*4] +
+                           src_pix[c+4-src_width*4] +
+
+                           src_pix[c-4] -8.0f* src_pix[c] +src_pix[c+4] +
+
+                           src_pix[c-4+src_width*4] + src_pix[c+src_width*4] +
+                           src_pix[c+4+src_width*4]) > 0.0f?
+                          gradient[c] : -1.0f*gradient[c];
         }
-        
+
         //alpha
         gradient[3] = src_pix[3];
-        
+
         for (c=0; c<4;c++)
           temp_buf[offset*4+c] = gradient[c];
-          
       }
-  
-  //1-pixel edges
 
+  //1-pixel edges
   offset = 0;
 
   for (y=0; y<dst_rect->height; y++)
@@ -180,12 +184,12 @@ edge_laplace (GeglBuffer          *src,
       {
 
         gfloat value[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-        
+
         gint c;
 
         gint i=x+LAPLACE_RADIUS, j=y+LAPLACE_RADIUS;
         gfloat *src_pix = temp_buf + (i + j * src_width) * 4;
-        
+
         for (c=0;c<3;c++)
         {
           gfloat current = src_pix[c];
@@ -199,16 +203,16 @@ edge_laplace (GeglBuffer          *src,
                       src_pix[c-4            ] < 0.0f ||
                       src_pix[c+4            ] < 0.0f))?
                     current : 0.0f;
-                    
+
           value[c] = current;
         }
-        
+
         //alpha
         value[3] = src_pix[3];
-        
+
         for (c=0; c<4;c++)
           dst_buf[offset*4+c] = value[c];
-          
+
         offset++;
       }
 
diff --git a/operations/common/edge-sobel.c b/operations/common/edge-sobel.c
index cfb3d9f..d9f5e22 100644
--- a/operations/common/edge-sobel.c
+++ b/operations/common/edge-sobel.c
@@ -30,10 +30,10 @@ gegl_chant_boolean (horizontal,  _("Horizontal"),  TRUE,
 
 gegl_chant_boolean (vertical,  _("Vertical"),  TRUE,
                     _("Vertical"))
-  
+
 gegl_chant_boolean (keep_signal,  _("Keep Signal"),  TRUE,
                     _("Keep Signal"))
-                  
+
 #else
 
 #define GEGL_CHANT_TYPE_AREA_FILTER
@@ -118,61 +118,63 @@ edge_sobel (GeglBuffer          *src,
         gfloat hor_grad[3] = {0.0f, 0.0f, 0.0f};
         gfloat ver_grad[3] = {0.0f, 0.0f, 0.0f};
         gfloat gradient[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-        
+
         gfloat *center_pix = src_buf + ((x+SOBEL_RADIUS)+((y+SOBEL_RADIUS) * src_width)) * 4;
-        
+
         gint c;
 
         if (horizontal)
-        {
-          gint i=x+SOBEL_RADIUS, j=y+SOBEL_RADIUS;
-          gfloat *src_pix = src_buf + (i + j * src_width) * 4;
-                  
-          for (c=0;c<3;c++)
-              hor_grad[c] += -1.0f*src_pix[c-4-src_width*4]+     src_pix[c+4-src_width*4] + \
-                             -2.0f*src_pix[c-4]            +2.0f*src_pix[c+4]             + \
-                             -1.0f*src_pix[c-4+src_width*4]+     src_pix[c+4+src_width*4];
-        }
-        
+          {
+            gint i=x+SOBEL_RADIUS, j=y+SOBEL_RADIUS;
+            gfloat *src_pix = src_buf + (i + j * src_width) * 4;
+
+            for (c=0;c<3;c++)
+                hor_grad[c] +=
+                    -1.0f*src_pix[c-4-src_width*4]+ src_pix[c+4-src_width*4] +
+                    -2.0f*src_pix[c-4] + 2.0f*src_pix[c+4] +
+                    -1.0f*src_pix[c-4+src_width*4]+ src_pix[c+4+src_width*4];
+          }
+
         if (vertical)
-        {
-          gint i=x+SOBEL_RADIUS, j=y+SOBEL_RADIUS;
-          gfloat *src_pix = src_buf + (i + j * src_width) * 4;
-                  
-          for (c=0;c<3;c++)
-              ver_grad[c] += -1.0f*src_pix[c-4-src_width*4]-2.0f*src_pix[c-src_width*4]-1.0f*src_pix[c+4-src_width*4] + \
-                                   src_pix[c-4+src_width*4]+2.0f*src_pix[c+src_width*4]+     src_pix[c+4+src_width*4];
+          {
+            gint i=x+SOBEL_RADIUS, j=y+SOBEL_RADIUS;
+            gfloat *src_pix = src_buf + (i + j * src_width) * 4;
+
+            for (c=0;c<3;c++)
+                ver_grad[c] +=
+                  -1.0f*src_pix[c-4-src_width*4]-2.0f*src_pix[c-src_width*4]-1.0f*src_pix[c+4-src_width*4] +
+                  src_pix[c-4+src_width*4]+2.0f*src_pix[c+src_width*4]+     src_pix[c+4+src_width*4];
         }
 
         if (horizontal && vertical)
-        {
-          for (c=0;c<3;c++)
-            // normalization to [0, 1]
-            gradient[c] = RMS(hor_grad[c],ver_grad[c])/1.41f; 
-        }
-        else
-        {
-          if (keep_signal)
           {
             for (c=0;c<3;c++)
-              gradient[c] = hor_grad[c]+ver_grad[c]; 
+              // normalization to [0, 1]
+              gradient[c] = RMS(hor_grad[c],ver_grad[c])/1.41f;
           }
-          else
+        else
           {
-            for (c=0;c<3;c++)
-                gradient[c] = fabsf(hor_grad[c]+ver_grad[c]); 
+            if (keep_signal)
+              {
+                for (c=0;c<3;c++)
+                  gradient[c] = hor_grad[c]+ver_grad[c];
+              }
+            else
+              {
+                for (c=0;c<3;c++)
+                  gradient[c] = fabsf(hor_grad[c]+ver_grad[c]);
+              }
           }
-        }
 
         //alpha
         gradient[3] = center_pix[3];
-        
+
         for (c=0; c<4;c++)
           dst_buf[offset*4+c] = gradient[c];
-          
+
         offset++;
       }
-      
+
   gegl_buffer_set (dst, dst_rect, babl_format ("RGBA float"), dst_buf,
                    GEGL_AUTO_ROWSTRIDE);
   g_free (src_buf);



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