[opengtl-commits] [407] add a bimedian demosaicing algorithm

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


Revision: 407
Author:   cyrille
Date:     2008-09-21 02:14:48 +0200 (Sun, 21 Sep 2008)

Log Message:
-----------
add a bimedian demosaicing algorithm

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/tests/raw/CMakeLists.txt
    trunk/OpenGTL/OpenShiva/tests/raw/LinearDemosaicing.shiva

Added Paths:
-----------
    trunk/OpenGTL/OpenShiva/tests/raw/BimedianDemosaicing.shiva
    trunk/OpenGTL/OpenShiva/tests/raw/BimedianDemosaicing.shiva.png


Added: trunk/OpenGTL/OpenShiva/tests/raw/BimedianDemosaicing.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/raw/BimedianDemosaicing.shiva	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/tests/raw/BimedianDemosaicing.shiva	2008-09-21 00:14:48 UTC (rev 407)
@@ -0,0 +1,95 @@
+kernel BimedianDemosaicing
+{
+  const float2 u_x = { 1, 0 };
+  const float2 u_y = { 0, 1 };
+  float m4 (float a_, float b_, float c_, float d_)
+  {
+    float t;
+    float a = a_;
+    float b = b_;
+    float c = c_;
+    float d = d_;
+  
+    /* Sort ab */
+    if (a > b)
+    {
+      t = b;
+      b = a;
+      a = t;
+    }
+    /* Sort abc */
+    if (b > c)
+    {
+      t = c;
+      c = b;
+      if (a > t)
+      {
+        b = a;
+        a = t;
+      } else {
+        b = t;
+      }
+    }
+    /* Return average of central two elements. */
+    if (d >= c) /* Sorted order would be abcd */
+    {
+      return (b + c) * 0.5;
+    } else if (d >= a) /* Sorted order would be either abdc or adbc */
+    {
+      return (b + d) * 0.5;
+    } else /* Sorted order would be dabc */
+    {
+      return (a + b) * 0.5;
+    }
+    return 1.0;
+  }
+  
+  void evaluatePixel(image1 img, out pixel4 result)
+  {
+    int x = result.coord[0];
+    int y = result.coord[1];
+    if( x & 1 )
+    {
+      if( y & 1 )
+      {
+        // B
+        //RGR
+        // B
+        result.data[0] = (img.sampleNearest( result.coord - u_x ) + img.sampleNearest( result.coord + u_x )) * 0.5;
+        result.data[1] = img.sampleNearest( result.coord );
+        result.data[2] = (img.sampleNearest( result.coord - u_y ) + img.sampleNearest( result.coord + u_y )) * 0.5;
+      } else {
+        //RGR
+        //GBG
+        //RGR
+        result.data[0] = m4(img.sampleNearest( result.coord - u_x - u_y ), img.sampleNearest( result.coord - u_x + u_y), img.sampleNearest( result.coord + u_x - u_y), img.sampleNearest( result.coord + u_x + u_y ) );
+        result.data[1] = m4(img.sampleNearest( result.coord - u_x ), img.sampleNearest( result.coord -u_y ), img.sampleNearest( result.coord + u_y ), img.sampleNearest( result.coord + u_x ) );
+        result.data[2] = img.sampleNearest( result.coord );
+      }
+    } else {
+      if( y & 1 )
+      {
+        //BGB
+        //GRG
+        //BGB
+        result.data[0] = img.sampleNearest( result.coord );
+        result.data[1] = m4(img.sampleNearest( result.coord - u_x ), img.sampleNearest( result.coord -u_y ), img.sampleNearest( result.coord + u_y ), img.sampleNearest( result.coord + u_x ) );
+        result.data[2] = m4(img.sampleNearest( result.coord - u_x - u_y ), img.sampleNearest( result.coord - u_x + u_y), img.sampleNearest( result.coord + u_x - u_y), img.sampleNearest( result.coord + u_x + u_y ) );
+      } else {
+        // R
+        //BGB
+        // R
+        result.data[0] = (img.sampleNearest( result.coord - u_y ) + img.sampleNearest( result.coord + u_y )) * 0.5;
+        result.data[1] = img.sampleNearest( result.coord );
+        result.data[2] = (img.sampleNearest( result.coord - u_x ) + img.sampleNearest( result.coord + u_x )) * 0.5;
+      }
+    }
+    
+    result.data[3] = 1.0;
+  }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+
+}

Added: trunk/OpenGTL/OpenShiva/tests/raw/BimedianDemosaicing.shiva.png
===================================================================
(Binary files differ)


Property changes on: trunk/OpenGTL/OpenShiva/tests/raw/BimedianDemosaicing.shiva.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/OpenGTL/OpenShiva/tests/raw/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/raw/CMakeLists.txt	2008-09-21 00:12:53 UTC (rev 406)
+++ trunk/OpenGTL/OpenShiva/tests/raw/CMakeLists.txt	2008-09-21 00:14:48 UTC (rev 407)
@@ -5,6 +5,7 @@
   SimpleDemosaicing.shiva
   LinearDemosaicing.shiva
   PixelGroupingPass1.shiva
+  BimedianDemosaicing.shiva
   )
 
 FOREACH( TEST_FILE ${TESTS_FILES} )

Modified: trunk/OpenGTL/OpenShiva/tests/raw/LinearDemosaicing.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/raw/LinearDemosaicing.shiva	2008-09-21 00:12:53 UTC (rev 406)
+++ trunk/OpenGTL/OpenShiva/tests/raw/LinearDemosaicing.shiva	2008-09-21 00:14:48 UTC (rev 407)
@@ -13,10 +13,16 @@
     {
       if( y & 1 )
       {
+        // B
+        //RGR
+        // B
         result.data[0] = (img.sampleNearest( coordAdj(result.coord, -1, 0) ) + img.sampleNearest( coordAdj(result.coord, 1, 0) )) * 0.5;
         result.data[1] = img.sampleNearest( result.coord );
         result.data[2] = (img.sampleNearest( coordAdj(result.coord, -1, 1) ) + img.sampleNearest( coordAdj(result.coord, 1, 1) )) * 0.5;
       } else {
+        // R
+        //GBG
+        // R
         result.data[0] = (img.sampleNearest( result.coord - 1 ) + img.sampleNearest( result.coord + 1 )) * 0.5;
         result.data[1] = (img.sampleNearest( coordAdj(result.coord, -1, 0) ) + img.sampleNearest( coordAdj(result.coord, 1, 0) )) * 0.5;
         result.data[2] = img.sampleNearest( result.coord );
@@ -24,10 +30,16 @@
     } else {
       if( y & 1 )
       {
+        // B
+        //GRG
+        // B
         result.data[0] = img.sampleNearest( result.coord );
         result.data[1] = (img.sampleNearest( coordAdj(result.coord, -1, 0) ) + img.sampleNearest( coordAdj(result.coord, 1, 0) )) * 0.5;
         result.data[2] = (img.sampleNearest( result.coord - 1) + img.sampleNearest( result.coord + 1)) * 0.5;
       } else {
+        // R
+        //BGB
+        // R
         result.data[0] = (img.sampleNearest( coordAdj(result.coord, -1, 1) ) + img.sampleNearest( coordAdj(result.coord, 1, 1) )) * 0.5;
         result.data[1] = img.sampleNearest( result.coord );
         result.data[2] = (img.sampleNearest( coordAdj(result.coord, -1, 0) ) + img.sampleNearest( coordAdj(result.coord, 1, 0) )) * 0.5;


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