[opengtl-commits] [749] add an attempt of seamlesser

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 749
Author:   cyrille
Date:     2009-05-29 19:48:09 +0200 (Fri, 29 May 2009)

Log Message:
-----------
add an attempt of seamlesser

Added Paths:
-----------
    trunk/shiva-collections/filters/Seamlesser.shiva


Added: trunk/shiva-collections/filters/Seamlesser.shiva
===================================================================
--- trunk/shiva-collections/filters/Seamlesser.shiva	                        (rev 0)
+++ trunk/shiva-collections/filters/Seamlesser.shiva	2009-05-29 17:48:09 UTC (rev 749)
@@ -0,0 +1,51 @@
+<
+  parameters: <
+    cellWidth: <
+      label: "Cell width";
+      type: int;
+      minValue: 1;
+      maxValue: 50;
+      defaultValue: 10;
+    >;
+    cellHeight: <
+      label: "Cell height";
+      type: int;
+      minValue: 1;
+      maxValue: 50;
+      defaultValue: 10;
+    >;
+  >;
+>;  
+kernel Seamlesser
+{  
+  float4 mix(float4 a, float4 b, float c)
+  {
+    return a * c + b * (1 - c);
+  }
+  float max(float a, float b)
+  {
+    if( a < b) return b;
+    return a;
+  }
+  float clamp(float a, float min, float max)
+  {
+    if( a < min ) return min;
+    if( a > max ) return max;
+    return a;
+  }
+  void evaluatePixel(image img, out pixel result)
+  {
+    float ax = result.coord.x / IMAGE_WIDTH;
+    float ay = result.coord.y / IMAGE_HEIGHT;
+    float x1 = max(0, ax - ay);
+    float y1 = max(0, ay - ax);
+    float x2 = min(1, ax + (1 - ay));
+    float y2 = min(1, ay + (1 - ax));
+    float weight = 0.5; //clamp(1 - (ax - x1) / (x2 - x1), 0, 1);
+    result = mix(img.sampleNearest( result.coord ), img.sampleNearest( IMAGE_SIZE - result.coord ), weight);
+  }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/